zoukankan      html  css  js  c++  java
  • AutoCompleteTextView控件的使用

    public class MainActivity extends Activity {
    
        //[0]声明AutoCompleteTextView要显示的数据
          private static final String[] COUNTRIES = new String[] {
                 "laofang", "laozhang", "laoli", "laobi","laoli","laowang","aab","abb","cc"
             };
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            //[1]找到控件
            AutoCompleteTextView actv = (AutoCompleteTextView) findViewById(R.id.actv);
            
            //[2]创建数据适配器
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                    android.R.layout.simple_dropdown_item_1line, COUNTRIES);
    
            //[3]设置数据适配器
            actv.setAdapter(adapter);
        }
    
    
    
    }
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        tools:context=".MainActivity" >
    
        <AutoCompleteTextView
            android:id="@+id/actv"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:completionThreshold="1"        
             />
    
    </RelativeLayout>
  • 相关阅读:
    LOJ#2244 起床困难综合症
    CF集萃2
    LOJ#2085 循环之美
    LOJ#2087 国王饮水记
    LOJ#2304 泳池
    人生中十个重要的健康伴侣
    web容器和servlet容器
    有关服务器,web 服务器,WEB容器的一点总结
    学习Java需要达到的25个目标
    EJB 规范
  • 原文地址:https://www.cnblogs.com/xufengyuan/p/6127169.html
Copyright © 2011-2022 走看看