android studio自动提示文本框
程序员文章站
2022-07-14 17:57:27
...
protected void onCreate(Bundle savedInstanceState) {
private String[] data1;
private ArrayAdapter adapter1 ;
private AutoCompleteTextView act_main_act1;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
act_main_act1=(AutoCompleteTextView)findViewById(R.id.act_main_cat1);//版本原因,有些需要强转有些不需要
//获取数据
data1 = new String[] { "愤怒的小鸟", "汤姆猫", "落汤鸡", "牛牛", "哈巴狗", "神龙", "烤鸭","小象", "美人鱼", "九尾狐" };
//创建适配器
adapter1 = new ArrayAdapter<String>( this,R.layout.act_main_item1,data1);
//绑定适配器
mtv_main_mtv1.setAdapter(adapter1);
}
}