Android MultiAutoCompleteTextview Using Kotlin With Example

We have recently published 100+ articles on android tutorials with kotlin and java. If you need, you may visit Android Tutorial for beginners page. You can also check Kotlin Tutorial for beginners. Also, if you are interested in content writing, you can mail us at

Hello Readers! In this post, we are going to learn about how to use android MultiAutoCompleteTextView using kotlin in any android application. We will also learn about different attributes of android MultiAutoCompleteTextview that can be used to customise this widget.


Tutorialwing Android MultiAutoCompleteTextView Output Android MultiAutoCompleteTextView using Kotlin

Tutorialwing Android MultiAutoCompleteTextView Output

Getting Started

MultiAutoCompleteTextView is an editable textView, extending AutoCompleteTextView, that can show completion suggestions for the substring of the text where the user is typing instead of necessarily for the entire thing.

Different Attributes of Android MultiAutoCompleteTextview Widget

Some of the popular attributes of MultiAutoCompleteTextView inherited from AutoCompleteTextView are –

Sr. XML Attributes Description
1 android:completionHint Sets hint shown in the dropdown menu
2 android:completionHintView Sets hint view shown in the dropdown menu
3 android:completionThreshold Sets number of character that user must type before suggestion is displayed in drop down menu
4 android:dropDownSelector Sets selector in dropdown list

Some of the popular attributes of MultiAutoCompleteTextView inherited from TextView are –

Sr. XML Attributes Description
1 android:height Sets height of the view
2 android:width Sets width of the view
3 android:textStyle Sets style of the text. For example, bold, italic or bolditalic etc.
4 android:textSize Sets Size of the text

Some of the popular attributes of MultiAutoCompleteTextView inherited from View are –

Sr. XML Attributes Description
1 android:alpha Sets alpha of the view
2 android:background Sets background of the view
3 android:clickable Sets whether view is clickable or not
4 android:focusable Sets whether view can take focus or not

Example of Android MultiAutoCompleteTextview Using Kotlin

1. Creating New Project in Kotlin

Follow steps below to create new project. Please ignore the steps if you have already created the project.

Step Description
1. Open Android Studio.
2. Go to File => New => New Project. Write application name as MultiAutoCompleteTextView. Then, check Include Kotlin Support and click next button.
3. Select minimum SDK you need. However, we have selected 17 as minimum SDK. Then, click next button
4. Then, select Empty Activity => click next => click finish.
5. You will get a newly created project successfully if you have followed steps properly.

2. Modify values folder

Open res/values/strings.xml file. Then, add below code into it.

	<string name="app_name">MultiAutoCompleteTextView</string>

	<string-array name="countries_array">
		<item>American Samoa</item>

3. Use MultiAutoCompleteTextview Widget in xml file

Open src/main/res/layout/activity_main.xml file and add below code into it.

<?xml version="1.0" encoding="utf-8"?>

		android:hint="Please enter something..."



In activity_main.xml file, we have defined MultiAutoCompleteTextView and Button widgets. Attributes android:hint=”” is used to set hint in the MultiAutoCompleteTextView.

4. Access MultiAutoCompleteTextview using Kotlin file

Open src/main/java/com.tutorialwing.multiautocompletetextview/MainActivity.kt file and add below code into it.

package com.tutorialwing.multiautocompletetextview

import android.os.Bundle
import android.widget.ArrayAdapter
import android.widget.Button
import android.widget.MultiAutoCompleteTextView
import android.widget.Toast

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {

        val multiAutoCompleteTextView = findViewById<MultiAutoCompleteTextView>(
        // Get the string array
        val countries = resources.getStringArray(R.array.countries_array)
        // Create the adapter and set it to the MultiAutoCompleteTextView
        val adapter = ArrayAdapter(this, android.R.layout.simple_list_item_1, countries)

        multiAutoCompleteTextView.threshold = 1

        val button = findViewById<Button>(
        button?.setOnClickListener {
            val text = "Entered text:" + " " + multiAutoCompleteTextView.text
            Toast.makeText(this@MainActivity, text, Toast.LENGTH_SHORT).show()

We have accessed MultiAutoCompleteTextView using kotlin file i.e. in MainActivity.kt file. Then, we have defined an adapter using array of strings i.e. countries_array, defined in strings.xml file.Then, we have set this adapter in multiAutoCompleteTextView. This adapter is responsible to display completion suggestions when user starts typing in the View.

Since AndroidManifest.xml file is very important in any android application, we are also going to see the content inside this file.

AndroidManifest.xml file

Code inside main/AndroidManifest.xml file is as below.

<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.tutorialwing.multiautocompletetextview"

		<activity android:name=".MainActivity">
				<action android:name="android.intent.action.MAIN"/>

				<category android:name="android.intent.category.LAUNCHER"/>


When we run the program, we will get output as shown above.

That’s end of our tutorial on Android MultiAutoCompleteTextView using Kotlin.

Support Us

If you like Tutorialwing and would like to contribute, you can email an article on any educational topic at We would love to publish your article. See your article on Tutorialwing and help others with your knowledge. Follow Facebook, LinkedIn, Google+, Twitter, Youtube for latest updates.
We have recently published 100+ articles on android tutorials with kotlin and java. If you need, you may visit Android Tutorial for beginners page. You can also check Kotlin Tutorial for beginners