{"id":1412,"date":"2016-04-18T04:35:44","date_gmt":"2016-04-18T04:35:44","guid":{"rendered":"http:\/\/abhiandroid.com\/ui\/?page_id=1412"},"modified":"2019-06-12T09:56:27","modified_gmt":"2019-06-12T09:56:27","slug":"multiautocompletetextview","status":"publish","type":"page","link":"https:\/\/abhiandroid.com\/ui\/multiautocompletetextview","title":{"rendered":"MultiAutoCompleteTextView\u00a0With Example In Android Studio"},"content":{"rendered":"<p>In Android, MultiAutoCompleteTextView is an editable TextView extends AutoCompleteTextView\u00a0that can show the complete suggestion for the sub-string of a text allowing user to quickly select\u00a0instead of typing whole. An AutoCompleteTextView\u00a0only offers suggestion about the whole sentence and a MultiAutoCompleteTextView\u00a0offers suggestion for every token in the sentence. We can specify what is the delimiter between tokens.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1527\" src=\"\/ui\/wp-content\/uploads\/2016\/04\/MultiAutoCompleteTextView-in-Android.jpg\" alt=\"MultiAutoCompleteTextView in Android\" width=\"342\" height=\"254\" srcset=\"https:\/\/abhiandroid.com\/ui\/wp-content\/uploads\/2016\/04\/MultiAutoCompleteTextView-in-Android.jpg 342w, https:\/\/abhiandroid.com\/ui\/wp-content\/uploads\/2016\/04\/MultiAutoCompleteTextView-in-Android-300x223.jpg 300w\" sizes=\"auto, (max-width: 342px) 100vw, 342px\" \/><\/p>\n<p><span style=\"color: #ff0000;\"><strong>Important\u00a0Note:<\/strong><\/span>\u00a0One most important difference between MultiAutoCompleteTextView and\u00a0AutoCompleteTextView is\u00a0that AutoCompleteTextView can hold or select only single value at single time but MultiAutoCompleteTextView can hold multiple string words value at single time. These all values are separated by comma(,).<\/p>\n<p><strong>Basic MultiAutoCompleteTextView code in XML:<\/strong><\/p>\n<pre>&lt;MultiAutoCompleteTextView\r\nandroid:id=\"@+id\/simpleMultiAutoCompleteTextView\"\r\nandroid:layout_width=\"fill_parent\"\r\nandroid:layout_height=\"wrap_content\"\r\nandroid:text=\"This Is A MultiAutoCompleteTextView\" \/&gt;\r\n<\/pre>\n<hr \/>\n<h4><strong>Adapter Used To Fill Data In\u00a0MultiAutoCompleteTextView<\/strong><\/h4>\n<p>To display the array content in a MultiAutoCompleteTextView we need to implement Adapter. In MultiAutoCompleteTextView, since we mainly display text values so we use ArrayAdapter for that. Below is the description of an ArrayAdapter.<\/p>\n<p><span style=\"color: #008000;\"><strong>ArrayAdapter In Android:<\/strong><\/span><\/p>\n<p>Whenever we have a list of single type of items which is backed by an array, we can use ArrayAdapter. For instance, list of phone contacts, countries or names.<\/p>\n<p><strong>ArrayAdapter code in Android:<\/strong><\/p>\n<pre>ArrayAdapter(Context context, int resource, int textViewResourceId, T[] objects)\r\n<\/pre>\n<p>In above code snippet we show the implementation of a ArrayAdapter. These 4 parameters are used to show the\u00a0list of elements in MultiAutoCompleteTextView\u00a0which\u00a0are already described in <a href=\"\/ui\/arrayadapter-tutorial-example.html\">ArrayAdapter tutorial<\/a>.<\/p>\n<hr \/>\n<h4><strong>Retrieving the Value From MultiAutoCompleteTextView In Java Class:<\/strong><\/h4>\n<p>Below is the example code where we retrieve the value from a MultiAutoCompleteTextView in Java class.<\/p>\n<pre>\/\/ initiate a MultiAutoCompleteTextView\r\nMultiAutoCompleteTextView simpleMultiAutoCompleteTextView = (MultiAutoCompleteTextView) findViewById(R.id.simpleMultiAutoCompleteTextView);\r\nString MultiAutoCompleteTextViewValue = simpleMultiAutoCompleteTextView.getText().toString(); \/\/ retrieve\u00a0 a value from MultiAutoCompleteTextView\r\n<\/pre>\n<hr \/>\n<h4><strong>Important Methods Of MultiAutoCompleteTextView:<\/strong><\/h4>\n<p>Let&#8217;s we discuss some important methods of MultiAutoCompleteTextView that that may be called in order to manage the MultiAutoCompleteTextView.<\/p>\n<p><span style=\"color: #008000;\"><strong>1.\u00a0<span class=\"sympad\">setTokenizer<\/span>(MultiAutoCompleteTextView.Tokenizer t): <\/strong><\/span>\u00a0This method sets the Tokenizer that will be used to determine the relevant range of the text where the user is typing. CommaTokenizer is used to set the tokenozer that distinguish the various substrings by comma.<\/p>\n<p>Below we set the CommaTokenizer for the MultiAutoCompleteTextView<\/p>\n<pre>\/\/ initiate a MultiAutoCompleteTextView\r\nMultiAutoCompleteTextView simpleMultiAutoCompleteTextView = (MultiAutoCompleteTextView) findViewById(R.id.simpleMultiAutoCompleteTextView);\r\n\/\/ set tokenizer that distinguish the various substrings by comma\r\nsimpleMultiAutoCompleteTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());<\/pre>\n<p><strong><span style=\"color: #008000;\">2. setThreshold(int threshold):\u00a0<\/span><\/strong><\/p>\n<p>This method is used to\u00a0set threshold value that help us to start the searching from a specific\u00a0character. In this we set int type value used to specify the threshold . Suppose if\u00a0set 1 value for threshold then on the time of typing searching is start from first character.<\/p>\n<p>Below we set 2\u00a0value for threshold that helps us to start the searching from second character.<\/p>\n<pre>\/\/ initiate a MultiAutoCompleteTextView\r\nMultiAutoCompleteTextView simpleMultiAutoCompleteTextView = (MultiAutoCompleteTextView) findViewById(R.id.simpleMultiAutoCompleteTextView);\r\n\/\/ set threshold value 2 that help us to start the searching from second character\r\nsimpleMultiAutoCompleteTextView.setThreshold(2);<\/pre>\n<hr \/>\n<h4><strong>Attributes of MultiAutoCompleteTextView:<\/strong><\/h4>\n<p>Now let\u2019s \u00a0we discuss\u00a0some important\u00a0attributes that help us to configure a MultiAutoCompleteTextView in xml file.<\/p>\n<p><span style=\"color: #008000;\"><strong>1. id:<\/strong><\/span>\u00a0This attribute is used to uniquely identify a MultiAutoCompleteTextView.<\/p>\n<pre>&lt;MultiAutoCompleteTextView\r\nandroid:id=\"@+id\/simpleMultiAutoCompleteTextView\"\r\nandroid:layout_width=\"fill_parent\"\r\nandroid:layout_height=\"wrap_content\"\r\nandroid:text=\"This Is A MultiAutoCompleteTextView\" \/&gt; &lt;!--\u00a0 id of a MultiAutoCompleteTextView that is used to uniquely identify it --&gt;\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>2. gravity:<\/strong><\/span> This is an optional attribute which is used to control the alignment of the text like left, right, center, top, bottom, center_vertical, center_horizontal etc.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1515\" src=\"\/ui\/wp-content\/uploads\/2016\/04\/gravity-in-MultiAutoCompleteTextView-Android.jpg\" alt=\"gravity in MultiAutoCompleteTextView Android\" width=\"288\" height=\"239\" \/><\/p>\n<p>Below we set the right gravity for text of a MultiAutoCompleteTextView\u00a0.<\/p>\n<pre>&lt;MultiAutoCompleteTextView\r\nandroid:id=\"@+id\/simpleMultiAutoCompleteTextView\"\r\nandroid:layout_width=\"fill_parent\"\r\nandroid:layout_height=\"wrap_content\"\r\nandroid:gravity=\"right\"\r\nandroid:text=\"AbhiAndroid.Com\" \/&gt; &lt;!--\u00a0 right gravity for the displayed text of MultiAutoCompleteTextView\u00a0--&gt;\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>3. text:<\/strong><\/span>\u00a0This\u00a0attribute is used to set the text in a MultiAutoCompleteTextView. We can set the text in xml as well as in the java class.<\/p>\n<p>In the above 2nd example we also used text attribute.<\/p>\n<p><strong>Setting text In MultiAutoCompleteTextView In Java class:<\/strong><\/p>\n<pre>MultiAutoCompleteTextView simpleMultiAutoCompleteTextView = (MultiAutoCompleteTextView) findViewById(R.id.simpleMultiAutoCompleteTextView);\r\nsimpleMultiAutoCompleteTextView.setText(\"AbhiAndroid\"); \/\/ set text in a MultiAutoCompleteTextView\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>4. hint:<\/strong><\/span>\u00a0This\u00a0attribute is used to set the hint that what should you enter in this MultiAutoCompleteTextView. Whenever user start to type in MultiAutoCompleteTextView the hint will automatically disappear.<\/p>\n<p>Below we set the hint of a MultiAutoCompleteTextView\u00a0.<\/p>\n<pre>&lt;MultiAutoCompleteTextView\r\nandroid:id=\"@+id\/simpleMultiAutoCompleteTextView\"\r\nandroid:layout_width=\"fill_parent\"\r\nandroid:layout_height=\"wrap_content\"\r\nandroid:hint=\"Enter Your Text Here\" \/&gt;&lt;!-- set hint in MultiAutoCompleteTextView --&gt;\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1524\" src=\"\/ui\/wp-content\/uploads\/2016\/04\/hint-in-MultiAutoCompleteTextView.gif\" alt=\"hint in MultiAutoCompleteTextView\" width=\"299\" height=\"387\" \/><\/p>\n<p><strong>Setting hint in\u00a0MultiAutoCompleteTextView In Java class:<\/strong><\/p>\n<pre>MultiAutoCompleteTextView simpleMultiAutoCompleteTextView = (MultiAutoCompleteTextView) findViewById(R.id.simpleMultiAutoCompleteTextView);\r\nsimpleMultiAutoCompleteTextView.setHint(\"Enter Your Text Here\"); \/\/ set hint in a MultiAutoCompleteTextView\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>5. textColor:<\/strong><\/span>\u00a0This\u00a0attribute is used to set the text color of a MultiAutoCompleteTextView. Color value is in the form of &#8220;#argb&#8221;, &#8220;#rgb&#8221;, &#8220;#rrggbb&#8221;, or &#8220;#aarrggbb&#8221;.<\/p>\n<p>Below we set the red color for the displayed text of a MultiAutoCompleteTextView.<\/p>\n<pre>&lt;MultiAutoCompleteTextView\r\nandroid:id=\"@+id\/simpleMultiAutoCompleteTextView\"\r\nandroid:layout_width=\"fill_parent\"\r\nandroid:layout_height=\"wrap_content\"\r\nandroid:text=\"AbhiAndroid.Com\"\r\nandroid:textColor=\"#f00\"\/&gt;\r\n&lt;!-- red color for the displayed text of a MultiAutoCompleteTextView --&gt;\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1516\" src=\"\/ui\/wp-content\/uploads\/2016\/04\/textColor-in-MultiAutoCompleteTextView-Android.jpg\" alt=\"textColor in MultiAutoCompleteTextView Android\" width=\"282\" height=\"234\" \/><\/p>\n<p><strong>Setting textColor In MultiAutoCompleteTextView In Java class:<\/strong><\/p>\n<pre>MultiAutoCompleteTextView simpleMultiAutoCompleteTextView = (MultiAutoCompleteTextView) findViewById(R.id.simpleMultiAutoCompleteTextView);\r\nsimpleMultiAutoCompleteTextView.setTextColor(Color.RED); \/\/ red color for the displayed text of a MultiAutoCompleteTextView\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>6. textColorHint:<\/strong><\/span>\u00a0This\u00a0attribute is used to set the color for\u00a0displayed hint text.<\/p>\n<p>Below we set the blue color for displayed hint of a MultiAutoCompleteTextView.<\/p>\n<pre>&lt;MultiAutoCompleteTextView\r\nandroid:id=\"@+id\/simpleMultiAutoCompleteTextView\"\r\nandroid:layout_width=\"fill_parent\"\r\nandroid:layout_height=\"wrap_content\"\r\nandroid:hint=\"Enter Your Text Here\"\r\nandroid:textColorHint=\"#00f\"\/&gt;\r\n&lt;!-- blue color for displayed hint text of a MultiAutoCompleteTextView --&gt;\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1523\" src=\"\/ui\/wp-content\/uploads\/2016\/04\/textColorHint-in-MultiAutoCompleteTextView-Android.jpg\" alt=\"textColorHint in MultiAutoCompleteTextView Android\" width=\"287\" height=\"216\" \/><\/p>\n<p><strong>Setting textColorHint In MultiAutoCompleteTextView In Java class:<\/strong><\/p>\n<pre>MultiAutoCompleteTextView simpleMultiAutoCompleteTextView = (MultiAutoCompleteTextView) findViewById(R.id.simpleMultiAutoCompleteTextView);\r\nsimpleMultiAutoCompleteTextView.setHintTextColor(Color.BLUE); \/\/ blue color for the displayed hint text of a MultiAutoCompleteTextView\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>7. textSize:<\/strong><\/span>\u00a0This\u00a0attribute is used to set the size of text of a MultiAutoCompleteTextView. We can set the text size in sp(scale independent pixel) or dp(density pixel).<\/p>\n<p>Below we set the 25sp size for the text of a MultiAutoCompleteTextView.<\/p>\n<pre>&lt;MultiAutoCompleteTextView\r\nandroid:id=\"@+id\/simpleMultiAutoCompleteTextView\"\r\nandroid:layout_width=\"fill_parent\"\r\nandroid:layout_height=\"wrap_content\"\r\nandroid:text=\"AbhiAndroid.Com\"\r\nandroid:textColor=\"#f00\"\r\nandroid:textSize=\"25sp\"\/&gt;&lt;!-- 25 sp text size of a\u00a0 MultiAutoCompleteTextView --&gt;\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1517\" src=\"\/ui\/wp-content\/uploads\/2016\/04\/textSize-in-MultiAutoCompleteTextView.jpg\" alt=\"textSize in MultiAutoCompleteTextView\" width=\"289\" height=\"233\" \/><\/p>\n<p><strong>Setting textSize In MultiAutoCompleteTextView \u00a0In Java class:<\/strong><\/p>\n<pre>MultiAutoCompleteTextView simpleMultiAutoCompleteTextView = (MultiAutoCompleteTextView) findViewById(R.id.simpleMultiAutoCompleteTextView);\r\nsimpleMultiAutoCompleteTextView.setTextSize(25); \/\/ 25 sp text size of a MultiAutoCompleteTextView\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>8. textStyle:<\/strong><\/span>\u00a0This\u00a0attribute is used to set the text style of a MultiAutoCompleteTextView. The possible text styles are bold, italic and normal. If we need to use two or more styles for a MultiAutoCompleteTextView then \u201c|\u201d operator is used for that.<\/p>\n<p>Below we set the bold style for the displayed text of a MultiAutoCompleteTextView.<\/p>\n<pre>&lt;MultiAutoCompleteTextView\r\nandroid:id=\"@+id\/simpleMultiAutoCompleteTextView\"\r\nandroid:layout_width=\"fill_parent\"\r\nandroid:layout_height=\"wrap_content\"\r\nandroid:text=\"AbhiAndroid.Com\"\r\nandroid:textColor=\"#f00\"\r\nandroid:textSize=\"25sp\"\r\nandroid:textStyle=\"bold\"\/&gt;&lt;!-- bold style for the displayed text of a MultiAutoCompleteTextView --&gt;\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1518\" src=\"\/ui\/wp-content\/uploads\/2016\/04\/textStyle-in-MultiAutoCompleteTextView.jpg\" alt=\"textStyle in MultiAutoCompleteTextView\" width=\"287\" height=\"237\" \/><\/p>\n<p><span style=\"color: #008000;\"><strong>9. background:<\/strong><\/span>\u00a0This\u00a0attribute is used to set the background of a MultiAutoCompleteTextView. We can set color or drawable(image or custom drawable xml) in the background of a MultiAutoCompleteTextView.<\/p>\n<p>Below we set the green color for the background and red color for the displayed text of a MultiAutoCompleteTextView.<\/p>\n<pre>&lt;MultiAutoCompleteTextView\r\nandroid:id=\"@+id\/simpleMultiAutoCompleteTextView\"\r\nandroid:layout_width=\"fill_parent\"\r\nandroid:layout_height=\"wrap_content\"\r\nandroid:text=\"AbhiAndroid.Com\"\r\nandroid:textColor=\"#f00\"\r\nandroid:textSize=\"25sp\"\r\nandroid:textStyle=\"bold\"\r\nandroid:background=\"#0f0\"\/&gt;&lt;!-- green background color of a MultiAutoCompleteTextView --&gt;\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1519\" src=\"\/ui\/wp-content\/uploads\/2016\/04\/background-in-MultiAutoCompleteTextView.jpg\" alt=\"background in MultiAutoCompleteTextView\" width=\"290\" height=\"210\" \/><\/p>\n<p><strong>Setting Background In\u00a0MultiAutoCompleteTextView In Java class:<\/strong><\/p>\n<pre>MultiAutoCompleteTextView simpleMultiAutoCompleteTextView = (MultiAutoCompleteTextView) findViewById(R.id.simpleMultiAutoCompleteTextView);\r\nsimpleMultiAutoCompleteTextView.setBackgroundColor(Color.GREEN); \/\/ green color for the background of a MultiAutoCompleteTextView\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>10. padding: <\/strong><\/span>This attribute is used to set the padding from left, right, top or bottom side of a MultiAutoCompleteTextView.<\/p>\n<ul>\n<li><strong>paddingRight: <\/strong>set the padding from the right side of a MultiAutoCompleteTextView<strong>.<\/strong><\/li>\n<li><strong>paddingLeft: <\/strong>set the padding from the left side of a MultiAutoCompleteTextView<strong>.<\/strong><\/li>\n<li><strong>paddingTop: <\/strong>set the padding from the top side of a MultiAutoCompleteTextView<strong>.<\/strong><\/li>\n<li><strong>paddingBottom: <\/strong>set the padding from the bottom side of a MultiAutoCompleteTextView<strong>.<\/strong><\/li>\n<li><strong>Padding: <\/strong>set the padding from the all side\u2019s of a MultiAutoCompleteTextView<strong>.<\/strong><\/li>\n<\/ul>\n<p>Below we set the 40dp padding from left side of a MultiAutoCompleteTextView.<\/p>\n<pre>&lt;MultiAutoCompleteTextView\r\nandroid:id=\"@+id\/simpleMultiAutoCompleteTextView\"\r\nandroid:layout_width=\"fill_parent\"\r\nandroid:layout_height=\"wrap_content\"\r\nandroid:text=\"AbhiAndroid.Com\"\r\nandroid:textColor=\"#f00\"\r\nandroid:textSize=\"25sp\"\r\nandroid:textStyle=\"bold\"\r\nandroid:background=\"#0f0\"\r\nandroid:paddingLeft=\"40dp\"\/&gt;\r\n&lt;!-- 40dp padding from left side of a MultiAutoCompleteTextView --&gt;\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1520\" src=\"\/ui\/wp-content\/uploads\/2016\/04\/padding-in-MultiAutoCompleteTextView-Android.jpg\" alt=\"padding in MultiAutoCompleteTextView Android\" width=\"279\" height=\"215\" \/><\/p>\n<p><strong><span style=\"color: #008000;\">11. drawableBottom, drawableTop, drawableRight And drawableLeft:<\/span>\u00a0<\/strong>These attribute draw the drawable below, top, right and left of the text of MultiAutoCompleteTextView.<\/p>\n<p>Below we set the icon to the Top\u00a0of the text of a MultiAutoCompleteTextView using drawableTop. In the similar way you can try for other three attribute yourself.<\/p>\n<p>First save image of ic_launcher name in drawable folder if it is not present and use the below code.<\/p>\n<pre>&lt;MultiAutoCompleteTextView\r\nandroid:id=\"@+id\/simpleMultiAutoCompleteTextView\"\r\nandroid:layout_width=\"fill_parent\"\r\nandroid:layout_height=\"wrap_content\"\r\nandroid:background=\"#0f0\"\r\nandroid:drawableTop=\"@drawable\/ic_launcher\"\r\nandroid:text=\"AbhiAndroid.Com\"\r\nandroid:gravity=\"center\"\r\nandroid:textColor=\"#f00\"\r\nandroid:textSize=\"25sp\"\r\nandroid:textStyle=\"bold\" \/&gt;\r\n&lt;!-- drawableTop of a MultiAutoCompleteTextView --&gt;\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1521\" src=\"\/ui\/wp-content\/uploads\/2016\/04\/drawable-in-MultiAutoCompleteTextView.jpg\" alt=\"drawable in MultiAutoCompleteTextView\" width=\"286\" height=\"223\" \/><\/p>\n<hr \/>\n<h4><strong>MultiAutoCompleteTextView Example In Android Studio<\/strong><\/h4>\n<p>Below is the example of MultiAutoCompleteTextView in which we display a MultiAutoCompleteTextView with suggestion list of android version names. To fill the data in this list we implement an array adapter. We set threshold value 1 that helps us to start the searching from first character.<\/p>\n<p>Below you can download complete project code, final output and step by step explanation of the example:<\/p>\n<p style=\"text-align: center;\"><a class=\"download\" href=\"https:\/\/github.com\/abhisheksaini4\/MultiAutoCompleteTextViewExample\" target=\"_blank\" rel=\"nofollow\">Download Code<\/a><a class=\"help\" title=\"Learn How To Download Code And Import In Android Studio\" href=\"\/androidstudio\/download-code-abhiandroid\" target=\"_blank\" rel=\"nofollow\"> ? <\/a><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1525\" src=\"\/ui\/wp-content\/uploads\/2016\/04\/MultiAutoCompleteTextView-Example-In-Android-Studio.gif\" alt=\"MultiAutoCompleteTextView Example In Android Studio\" width=\"302\" height=\"405\" \/><\/p>\n<p><span style=\"color: #008000;\"><strong>Step 1<\/strong><\/span><strong><span style=\"color: #008000;\">:<\/span>\u00a0<\/strong>Create a new project and name it\u00a0MultiAutoCompleteTextView<\/p>\n<p><span style=\"color: #008000;\"><strong>Step 2:<\/strong><\/span><strong>\u00a0<\/strong>Open res -&gt; layout -&gt;activity_main.xml (or) main.xml and add following code :<\/p>\n<p>In this step we open an xml file and add the code for displaying a MultiAutoCompleteTextView by using its different attributes.<\/p>\n<pre>&lt;RelativeLayout xmlns:android=\"http:\/\/schemas.android.com\/apk\/res\/android\"\r\nxmlns:tools=\"http:\/\/schemas.android.com\/tools\"\r\nandroid:layout_width=\"match_parent\"\r\nandroid:layout_height=\"match_parent\"\r\nandroid:paddingBottom=\"@dimen\/activity_vertical_margin\"\r\nandroid:paddingLeft=\"@dimen\/activity_horizontal_margin\"\r\nandroid:paddingRight=\"@dimen\/activity_horizontal_margin\"\r\nandroid:paddingTop=\"@dimen\/activity_vertical_margin\"\r\ntools:context=\".MainActivity\"&gt;\r\n\r\n\r\n&lt;!--\u00a0 MultiAutoCompleteTextView In Android --&gt;\r\n&lt;MultiAutoCompleteTextView\r\nandroid:id=\"@+id\/simpleMultiAutoCompleteTextView\"\r\nandroid:layout_width=\"fill_parent\"\r\nandroid:layout_height=\"wrap_content\"\r\nandroid:background=\"#0f0\"\r\nandroid:gravity=\"center\"\r\nandroid:hint=\"Enter Your Text Here\"\r\nandroid:padding=\"10dp\"\r\nandroid:textColor=\"#f00\"\r\nandroid:textSize=\"20sp\"\r\nandroid:textStyle=\"bold\" \/&gt;\r\n\r\n&lt;\/RelativeLayout&gt;\r\n<\/pre>\n<p><span style=\"color: #008000;\"><strong>Step 3:<\/strong><\/span><strong>\u00a0<\/strong>Open\u00a0 \u00a0src -&gt; package -&gt; MainActivity.java<\/p>\n<p>In this step we open\u00a0MainActivity\u00a0and\u00a0add the code to\u00a0initiate the MultiAutoCompleteTextView and then add the data to suggestion list using an ArrayAdapter. In this we also set threshold value 1 that helps us to start the searching from first character.<\/p>\n<pre>package example.abhiandroid.multiautocompletetextviewexample;\r\n\r\nimport android.os.Bundle;\r\nimport android.support.v7.app.AppCompatActivity;\r\nimport android.widget.ArrayAdapter;\r\nimport android.widget.MultiAutoCompleteTextView;\r\n\r\npublic class MainActivity extends AppCompatActivity {\r\n\r\nString[] androidVersionNames = {\"Aestro\", \"Blender\", \"CupCake\", \"Donut\", \"Eclair\", \"Froyo\", \"Gingerbread\", \"HoneyComb\", \"IceCream Sandwich\", \"Jellibean\", \"Kitkat\", \"Lollipop\", \"MarshMallow\"};\r\n\r\n@Override\r\nprotected void onCreate(Bundle savedInstanceState) {\r\nsuper.onCreate(savedInstanceState);\r\nsetContentView(R.layout.activity_main);\r\n\/\/ initiate a MultiAutoCompleteTextView\r\nMultiAutoCompleteTextView simpleMultiAutoCompleteTextView = (MultiAutoCompleteTextView) findViewById(R.id.simpleMultiAutoCompleteTextView);\r\n\/\/ set adapter to fill the data in suggestion list\r\nArrayAdapter&lt;String&gt; versionNames = new ArrayAdapter&lt;String&gt;(this, android.R.layout.simple_list_item_1, androidVersionNames);\r\nsimpleMultiAutoCompleteTextView.setAdapter(versionNames);\r\n\r\n\/\/ set threshold value 1 that help us to start the searching from first character\r\nsimpleMultiAutoCompleteTextView.setThreshold(1);\r\n\/\/ set tokenizer that distinguish the various substrings by comma\r\nsimpleMultiAutoCompleteTextView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());\r\n}\r\n}\r\n<\/pre>\n<p><strong>Output:<\/strong><\/p>\n<p>Now run the App and you will see MultiAutoCompleteTextView. Here enter any character and corresponding Android version to that character will appear. Select it and do the same with other Android version. You can see it can hold more than one value which was not possible with AutoCompleteTextView.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In Android, MultiAutoCompleteTextView is an editable TextView extends AutoCompleteTextView\u00a0that can show the complete suggestion for the sub-string of a text allowing user to quickly select\u00a0instead of typing whole. An AutoCompleteTextView\u00a0only offers suggestion about the whole sentence and a MultiAutoCompleteTextView\u00a0offers suggestion for every token in the sentence. We can specify what is the delimiter between tokens. &hellip; <a href=\"https:\/\/abhiandroid.com\/ui\/multiautocompletetextview\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">MultiAutoCompleteTextView\u00a0With Example In Android Studio<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"open","ping_status":"closed","template":"home.php","meta":{"_acf_changed":false,"footnotes":""},"class_list":["post-1412","page","type-page","status-publish","hentry"],"acf":[],"psp_head":"<title>MultiAutoCompleteTextView\u00a0With Example In Android Studio \u2013 Abhi Android<\/title>\r\n<meta name=\"description\" content=\"In Android, MultiAutoCompleteTextView is an editable TextView extends AutoCompleteTextView\u00a0that can show the complete suggestion for the sub-string.\" \/>\r\n<meta name=\"robots\" content=\"index,follow\" \/>\r\n<link rel=\"canonical\" href=\"https:\/\/abhiandroid.com\/ui\/multiautocompletetextview\" \/>\r\n","_links":{"self":[{"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/pages\/1412","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/comments?post=1412"}],"version-history":[{"count":3,"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/pages\/1412\/revisions"}],"predecessor-version":[{"id":2792,"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/pages\/1412\/revisions\/2792"}],"wp:attachment":[{"href":"https:\/\/abhiandroid.com\/ui\/wp-json\/wp\/v2\/media?parent=1412"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}