带下拉列表提示语的TextView

来源:互联网 发布:linux下如何删除用户 编辑:程序博客网 时间:2024/05/01 11:03
public class HintTextView extends Activity{    private AutoCompleteTextView autoCompleteTextView;    private MultiAutoCompleteTextView multiAutoCompleteTextView;    private String datas [] = {"qqqq","qqaaa","fasffsaf","fasdfwerf","qqdfsasf"};    @Override    protected void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.activity_hint_text_view);        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,datas);        //不带连续提示         autoCompleteTextView =                (AutoCompleteTextView) findViewById(R.id.AutoCompleteTextView);        autoCompleteTextView.setAdapter(adapter);
        //带连续提示         multiAutoCompleteTextView =
(MultiAutoCompleteTextView) findViewById(R.id.MultiAutoCompleteTextView); multiAutoCompleteTextView.setAdapter(adapter); multiAutoCompleteTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer()); }}
<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"    android:layout_width="match_parent"    android:layout_height="match_parent"    android:orientation="vertical">    
    <!--android:completionThreshold="2" 输入几个文字开始提示-->    <AutoCompleteTextView
android:id="@+id/AutoCompleteTextView" android:layout_width="match_parent" android:layout_height="wrap_content" android:completionThreshold="2"/> <MultiAutoCompleteTextView android:id="@+id/MultiAutoCompleteTextView" android:layout_width="match_parent" android:layout_height="wrap_content" android:completionThreshold="2"/></LinearLayout>
1 0
原创粉丝点击