Android自动提示控件AutoCompleteTextView
时间:2021-04-08 10:38:15|栏目:Android代码|点击: 次
在输入框中输入我们想要输入的信息就会出现其他与其相关的提示信息,这种效果在Android中是用AutoCompleteTextView实现的。

<AutoCompleteTextView android:layout_width="match_parent" android:layout_height="wrap_content" android:id="@+id/autotext" />
public class MainActivity extends Activity {
private AutoCompleteTextView autotext;
private ArrayAdapter<String> arrayAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.test);
autotext =(AutoCompleteTextView) findViewById(R.id.autotext);
String [] arr={"aa","aab","aac"};
arrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,arr);
autotext.setAdapter(arrayAdapter);
}
}

栏 目:Android代码
下一篇:详解Flutter 调用 Android Native 的方法
本文标题:Android自动提示控件AutoCompleteTextView
本文地址:http://www.codeinn.net/misctech/96893.html






