Android用戶界面開發(fā)之:TextView的使用實例
更新時間:2013年05月20日 10:29:08 作者:
Android用戶界面開發(fā)之:TextView的使用實例,需要的朋友可以參考一下
TextView就是一個用來顯示文本標簽的控件。
復(fù)制代碼 代碼如下:
/*TextView的設(shè)置*//* 獲得TextView對象 */
textview = (TextView)this.findViewById(R.id.textview);
String string = "TextView示例!";
/* 設(shè)置文本的顏色 */
textview.setTextColor(Color.RED);
/* 設(shè)置字體大小 */
textview.setTextSize(20);
/* 設(shè)置文字背景 */
textview.setBackgroundColor(Color.BLUE);
/* 設(shè)置TextView顯示的文字 */
textview.setText(string);
復(fù)制代碼 代碼如下:
/*TextView顯示網(wǎng)頁*/textView1 = (TextView) this.findViewById(R.id.textview1);
textView2 = (TextView) this.findViewById(R.id.textview2);
// 添加一段html的標志
String html = "<font color='red'>I love android</font><br>";
html += "<font color='#0000ff'><big><i>I love android</i></big></font><p>";
html += "<big><a href='http://www.dbjr.com.cn'>腳本之家</a></big>";
CharSequence charSequence = Html.fromHtml(html);
textView1.setText(charSequence);
textView1.setMovementMethod(LinkMovementMethod.getInstance());// 點擊的時候產(chǎn)生超鏈接
String text = "我的URL:http://www.dbjr.com.cn\n";
text += "我的email:****** @gmail.com\n";
text += "我的電話:+ 86 137********";
textView2.setText(text);
textView2.setMovementMethod(LinkMovementMethod.getInstance());
相關(guān)文章
Android OKHttp框架的分發(fā)器與攔截器源碼刨析
okhttp是一個第三方類庫,用于android中請求網(wǎng)絡(luò)。這是一個開源項目,是安卓端最火熱的輕量級框架,由移動支付Square公司貢獻(該公司還貢獻了Picasso和LeakCanary) 。用于替代HttpUrlConnection和Apache HttpClient2022-11-11Android中給fragment寫入?yún)?shù)的輕量開發(fā)包FragmentArgs簡介
這篇文章主要介紹了Android中給fragment寫入?yún)?shù)的輕量開發(fā)包FragmentArgs簡介,需要的朋友可以參考下2014-10-10Android Studio實現(xiàn)簡易進制轉(zhuǎn)換計算器
這篇文章主要為大家詳細介紹了Android Studio實現(xiàn)簡易進制轉(zhuǎn)換計算器,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下2022-05-05