Android user input auto prompt control AutoCompleteTextView usage
1、 Introduction
1. The role of AutoCompleteTextView
2. Class structure diagram of AutoCompleteTextView
That is, it has various functions of EditText
3. How AutoCompleteTextView works
The auto prompt function of AutoCompleteTextView certainly requires the adapter to provide data
4. Adapter in Android
5. Adapter for AutoCompleteTextView
ArrayAdapter
2、 AutoCompleteTextView method for realizing automatic prompt
1) AutoCompleteTextView method for realizing automatic prompt
Step 1: create an adapter
String [] arr = {"Caesar", "Caesar square", "Caesar the great"}; ArrayAdapter<String> adapter= new ArrayAdapter<String>(this,R.layout.textview,arr);
Step 2: AutoCompleteTextView object application adapter
autoCompleteTextView1.setAdapter(adapter);
explain:
The prompt text is implemented by textview. The prompt data in the prompt text is string [] arr.
3、 Code example
code:
fry.Activity01
fry.Activity01
/AutoCompleteTextViewDemo1/res/layout/textview.xml
4、 Error prone point
1. This is the direct textview, not the textview under layout
/AutoCompleteTextViewDemo1/res/layout/textview.xml
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.