AutoCompleteTextView :
ACTV is one of the UI component in Android which is used to provide an auto
completion support to the user it is a subtype of EditText component.
xml :
AutoCompleteTextView
android:id=“@+id/ACTV”
…………………. /
Kotlin :
AutoCompleteTextView actv=(AutoCompleteTextView) findViewById(R.id.ACTV);//Not Required in kotlin
To provide auto completion support we have to configure the values, in android there are 2
ways to configure the values
XML
Kotlin
XML :
res -- values -- strings.xml
string-array name=“array_name”
item value1 /item
item value2 /item
…………….
/string-array
use the following code in Kotlin to get these configured values.
var values=resources.getStringArray(R.array.array_name)
Kotlin :
var values=arrayOf(“value1”,”value2”,….)
(or)
var list = ArrayList String ()
list.add(value1);
list.add(value2);
list.add(value3);
…………..
to present the values we have to create an adapter, in android there are 3 types of adapters
Array Adapter
Custom Adapter
Cursor Adapter
ArrayAdapter :
syntax :
var adapter= ArrayAdapter String
(context, xml_file,values);
ACTV.setAdapter(adapter);
ACTV.setThreshold(int);
code sample :
String[] values=getResources().getStringArray(R.array.countries);
ArrayAdapter String adapter=ArrayAdapter String(this@MainActivity,android.R.layout.simple_expandable_list_item_1,list)
AutoCompleteTextView ACTV=(AutoCompleteTextView)findViewById(R.id.ACTV);//This not required in kotlin
ACTV.setAdapter(adapter)
ACTV.threshold=1
~-~~-~~~-~~-~
Please watch: "MySQL Database connection in java 12 using eclipse 2019"
• MySQL Database connection in java 12 ...
~-~~-~~~-~~-~
Watch video AutoCompleteTextView in Android (Kotlin) || there are two ways to configure the values online without registration, duration hours minute second in high quality. This video was added by user Technical Babaji (Tarique Akhtar) 16 July 2018, don't forget to share it with your friends and acquaintances, it has been viewed on our site 2,320 once and liked it 16 people.