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.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>