展会信息港展会大全

android 使用AutoCompleteTextView控件的步骤
来源:互联网   发布日期:2015-11-15 10:20:29   浏览:1331次  

导读:第一步:在布局文件中定义控件AutoCompleteTextViewandroid:id=@+id/actvandroid:layout_width=fill_parentandroid:layout_height=wrap_content/第二步:在Activity中引用AutoCompleteTextViewactv=(Aut......

第一步:在布局文件中定义控件

<AutoCompleteTextView

android:id="@+id/actv"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

/>

第二步:在Activity中引用

AutoCompleteTextView actv = (AutoCompleteTextView) findViewById(R.id.actv);

第三步:创建一个适配器来保存数据

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,

android.R.layout.simple_dropdown_item_1line,new String[] {"English", "Hebrew", "Hindi", "German" });

第四步:将适配器与AutoCompleteTextView相关联

actv.setAdapter(adapter);

赞助本站

人工智能实验室

相关热词: AutoCompleteTextView

AiLab云推荐
展开

热门栏目HotCates

Copyright © 2010-2024 AiLab Team. 人工智能实验室 版权所有    关于我们 | 联系我们 | 广告服务 | 公司动态 | 免责声明 | 隐私条款 | 工作机会 | 展会港