在Android中,TextView的一些应用小例子:
package com.andy.android;
import android.app.Activity;
import android.os.Bundle;
import android.text.util.Linkify;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.TextView;
/**
* TextView 应用例子
* @author Andy.Zhang
*
*/
public class TestTextView extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//1、自动检查超链接
TextView tv = (TextView) findViewById(com.andy.android.R.id.textview);
tv.setText("访问我的javaeye博客 http://andyzhchy.iteye.com/");
Linkify.addLinks(tv, Linkify.ALL);
//2、自动填充
AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView)findViewById(R.id.auto_complete);
ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line,new String[]{
"aa", "ab", "bc", "de", "ac","aab"
});
autoCompleteTextView.setAdapter(arrayAdapter);
}
}
布局文件main.xml代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView android:id="@+id/textview" android:layout_width="fill_parent"
android:layout_height="40dip" />
<AutoCompleteTextView android:id="@+id/auto_complete"
android:layout_width="fill_parent" android:layout_height="wrap_content" />
</LinearLayout>
分享到:
相关推荐
Android 使用SpannableString在TextView中插入表情、超链接、文字变大、加粗,附源码及apk
解决TextView的排版问题-自动换行
本文实例讲述了android:TextView简单设置文本样式和超链接的方法。分享给大家供大家参考,具体如下: 设置TextView中文本的样式(如:颜色、斜体等),可以针对不同位置的文本设置不同的样式(如:将索引范围在1-3的...
WebView跳转TextView中的超链接,支持多行链接,可以实现一行文本显示多个链接
使用TextView的autoLink属性设置超链接,用工具类方式和自定义View方式两种方式修改超链接显示样式和链接地址的点击事件。
Android源代码 TextView超链接实现用了2种方法: (1) XML文件实现 (2) java源代码实现
AndroidRichText帮助实现像QQ,微信一样的,一个TextView里既有文字又有表情又有图片的效果,采用插件化的框架,代码简单,可拓展性强。 基础框架包只有四个java文件, RichTextWrapper :TextView的包裹类,实现...
android TextView解决自动换行问题,设置行数后超过用省略号
本文实例讲述了Android使用TextView实现无下划线超链接的方法。分享给大家供大家参考,具体如下: Android系统默认把网址、电话、地图(geo地址)、邮箱等转换为超链接。 具体请查看 android:TextView简单设置文本样式...
Android TextView自动滚动,可以上下自动滚动也可以左右自动滚动,使用方便
自动调整文本视图Android TextView,其中文本字体大小自动调整为其高度和宽度
android下textview 显示html片段,可以显示文字和图片混排,图片可以是网络图片
TextView超链接自定义样式,包含自定义字体颜色和去掉超链接下划线
本示例代码为博客代码:博客地址为:http://blog.csdn.net/zhangjinhuang/article/details/52416608
常用控件:TextView EditText Button 项目文件
android开发中在textview中添加超链接的几种方法
NULL 博文链接:https://sarin.iteye.com/blog/1567318
NULL 博文链接:https://lovezhou.iteye.com/blog/905446
TextView的超链接字和不同色彩效果.rar,太多无法一一验证是否可用,程序如果跑不起来需要自调,部分代码功能进行参考学习。