欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android開發(fā)實(shí)現(xiàn)TextView顯示豐富的文本

 更新時(shí)間:2015年12月25日 12:36:42   作者:sgx425021234  
這篇文章主要介紹了Android開發(fā)實(shí)現(xiàn)TextView顯示豐富的文本,涉及Android中TextView的使用技巧,需要的朋友可以參考下

本文實(shí)例講述了Android開發(fā)實(shí)現(xiàn)TextView顯示豐富的文本的方法。分享給大家供大家參考,具體如下:

如圖,顯示html的元素控件,點(diǎn)擊連接實(shí)現(xiàn)上網(wǎng),發(fā)email,撥號

實(shí)現(xiàn)源碼如下:

MainActivity.java

package com.example.textview2;
import android.os.Bundle;
import android.app.Activity;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.Menu;
import android.widget.TextView;
public class MainActivity extends Activity {
  private TextView textView1, textView2;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    textView1 = (TextView) this.findViewById(R.id.textview1);
    textView2 = (TextView) this.findViewById(R.id.textview2);
    // 添加一段html的標(biāo)志
    String html = "<font color='red'></font><br><br><br>";
    html += "<font color='#0000ff'><big><i></i></big></font><p>";
    html += "<big><a ;
    CharSequence charSequence = Html.fromHtml(html);
    textView1.setText(charSequence);
    textView1.setMovementMethod(LinkMovementMethod.getInstance());// 點(diǎn)擊的時(shí)候產(chǎn)生超鏈接
    String text = "我的URL:http://www.sina.com\n";
    text += "我的email:abcd@126.com\n";
    text += "我的電話:+ 86 010-89487389";
    textView2.setText(text);
    textView2.setMovementMethod(LinkMovementMethod.getInstance());
  }
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.main, menu);
    return true;
  }
}

strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
  <string name="action_settings">Settings</string>
  <string name="hello_world">Hello world!</string>
  <string name="app_name">如何顯示html的元素控件</string>
  <color name="green">#00FF00</color>
  <string name="link_text"><a href="tel:13693207964">打電話</a></string>
</resources>

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context=".MainActivity" >
  <TextView android:layout_width="fill_parent"
    android:layout_height="wrap_content" android:id="@+id/textview1"
    android:padding="20sp" />
  <TextView
    android:id="@+id/textview2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:autoLink="all"
    android:padding="20sp"
    android:text="@string/link_text"
    android:textSize="20sp" />
</RelativeLayout>

希望本文所述對大家Android程序設(shè)計(jì)有所幫助。

相關(guān)文章

  • Android高級組件Gallery畫廊視圖使用方法詳解

    Android高級組件Gallery畫廊視圖使用方法詳解

    這篇文章主要為大家詳細(xì)介紹了Android高級組件Gallery畫廊視圖的使用方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-12-12
  • Android使用觀察者模式Observer實(shí)現(xiàn)網(wǎng)絡(luò)狀態(tài)監(jiān)聽

    Android使用觀察者模式Observer實(shí)現(xiàn)網(wǎng)絡(luò)狀態(tài)監(jiān)聽

    這篇文章主要為大家詳細(xì)介紹了Android使用觀察者模式Observer實(shí)現(xiàn)網(wǎng)絡(luò)狀態(tài)監(jiān)聽,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-05-05
  • 實(shí)例講解Android自定義控件

    實(shí)例講解Android自定義控件

    本篇文章通過實(shí)例給大家講解了Android自定義控件的使用技巧和需要注意的地方,跟著學(xué)習(xí)參考下吧。
    2017-12-12
  • Android可自定義垂直循環(huán)滾動(dòng)布局

    Android可自定義垂直循環(huán)滾動(dòng)布局

    這篇文章主要為大家詳細(xì)介紹了Android可自定義垂直循環(huán)滾動(dòng)布局,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-03-03
  • Android基于opencv實(shí)現(xiàn)多通道分離與合并

    Android基于opencv實(shí)現(xiàn)多通道分離與合并

    針對圖像多通道的分離與混合,OpenCV 4中提供了split()函數(shù)和merge()函數(shù)用于解決這些需求。本文講解一下Android如何調(diào)用這些函數(shù)實(shí)現(xiàn)多通道分離與合并
    2021-06-06
  • Android實(shí)現(xiàn)果凍滑動(dòng)效果的控件

    Android實(shí)現(xiàn)果凍滑動(dòng)效果的控件

    這篇文章給大家主要介紹了利用Android如何實(shí)現(xiàn)果凍效果滑動(dòng)效果的控件,實(shí)現(xiàn)的效果類似于iOS有阻尼效果的滑動(dòng)控件,一般我們比較親切地稱之為果凍控件,常見的如微信里[我]的那個(gè)面板模塊,即使沒有再多的選項(xiàng),也不會(huì)很生硬的不允許用戶滑動(dòng)。下面來一起看看吧。
    2016-11-11
  • Android多點(diǎn)觸控技術(shù)實(shí)戰(zhàn) 針對圖片自由縮放和移動(dòng)

    Android多點(diǎn)觸控技術(shù)實(shí)戰(zhàn) 針對圖片自由縮放和移動(dòng)

    這篇文章主要為大家詳細(xì)介紹了Android多點(diǎn)觸控技術(shù)實(shí)戰(zhàn),自由地對圖片進(jìn)行縮放和移動(dòng),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-10-10
  • Flutter實(shí)現(xiàn)仿微信分享功能的示例代碼

    Flutter實(shí)現(xiàn)仿微信分享功能的示例代碼

    Flutter 用來快速開發(fā) Android iOS平臺應(yīng)用,在Flutter 中,通過 fluwx或者fluwx_no_pay 插件可以實(shí)現(xiàn)微信分享功能,本文將具體介紹實(shí)現(xiàn)的示例代碼,需要的可以參考一下
    2022-01-01
  • android 日志文件LogUtils實(shí)例

    android 日志文件LogUtils實(shí)例

    這篇文章主要介紹了android 日志文件LogUtils實(shí)例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-08-08
  • 詳解Android 硬布局item的高級寫法

    詳解Android 硬布局item的高級寫法

    這篇文章主要介紹了詳解Android 硬布局item的高級寫法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-12-12

最新評論