• AutoCompleteTextview、MultiAutoCompleteTextView


    AutoCompleteTextview
        动态匹配输入内容文本框
         属性:
              android:completionThreshold="2";     设置输入多少字符时自动匹配
     
    public class MainActivity extends ActionBarActivity {
            private AutoCompleteTextView actextview ;
            //初始化数据源  去匹配文本框中输入的内容
            private String[] res ={"北京" ,"北京1" ,"北京2" ,"上海" ,"上海1" ,"上海2" };
           
            @Override
            protected void onCreate(Bundle savedInstanceState) {
                   super.onCreate(savedInstanceState);
                  setContentView(R.layout. activity_main);
                   //初始化控件
                   actextview=(AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1 );
                   //New适配器
                  ArrayAdapter<String> adapter= new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1 ,res );
                   //将adpter 与当前AutoCompleteTextView控件绑定
                   actextview.setAdapter(adapter);
           }
    }
     
     
    <AutoCompleteTextView
            android:id="@+id/autoCompleteTextView1"
            android:layout_width="match_parent"
            android:layout_height="50dp"
            android:completionThreshold="1"
            android:hint="@string/AutoCompleteTextView" >
            <requestFocus />
        </AutoCompleteTextView >
     
     
     
     
     
    MultiAutoCompleteTextView
         可支持选择多个值(在多次输入的情况下),分别用分隔符分开,并且在每个字选中的时候再次输入值时会自动去匹配。(AutoCompleteTextview 单选)
           android:completionThreshold="2";     设置输入多少字符时自动匹配
            mtxt.setTokenizer(new MultiAutoCompleteTextView.CommTokenizer());
    maTextView=(MultiAutoCompleteTextView) findViewById(R.id.multiAutoCompleteTextView1 );
    maTextView.setAdapter(adapter);
    //设置分隔符
    maTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
    stareblankly.cn
  • 相关阅读:
    编辑器、编译器、文件、IDE等常见概念辨析
    二叉排序树的实现
    模板
    Codeforces Round #690 (Div. 3)
    Educational Codeforces Round 100 (Rated for Div. 2)
    Codeforces 414-B. Mashmokh and ACM(数位dp)
    Codeforces 339D-Xenia and Bit Operations(线段树)
    Educational Codeforces Round 96 (Rated for Div. 2) 题解
    2019-2020 ICPC Northwestern European Regional Programming Contest (NWERC 2019)
    2018-2019 ICPC Northwestern European Regional Programming Contest (NWERC 2018)
  • 原文地址:https://www.cnblogs.com/stareblankly/p/4829239.html
Copyright © 2020-2023  润新知