Android开发便签3:TextView的自动检测文本中的超链接和自动补全
2010-07-01 15:12:00 来源:WEB开发网@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.javaeye.com/");
Linkify.addLinks(tv, Linkify.ALL);
//2、自动填充
AutoCompleteTextView autoCompleteTextView = (AutoCompleteTextView)findViewById(R.id.auto_complete);
ArrayAdapter
android.R.layout.simple_dropdown_item_1line,new String[]{
"aa", "ab", "bc", "de", "ac","aab"
});
autoCompleteTextView.setAdapter(arrayAdapter);
}
}
布局文件main.xml代码:
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>
更多精彩
赞助商链接