C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML
Android AutoCompleteTextView ExampleAndroid AutoCompleteTextView completes the word based on the reserved words, so no need to write all the characters of the word. Android AutoCompleteTextView is a editable text field, it displays a list of suggestions in a drop down menu from which user can select only one suggestion or value. Android AutoCompleteTextView is the subclass of EditText class. The MultiAutoCompleteTextView is the subclass of AutoCompleteTextView class. Android AutoCompleteTextView ExampleIn this example, we are displaying the programming languages in the autocompletetextview. All the programming languages are stored in string array. We are using the ArrayAdapter class to display the array content. Let's see the simple example of autocompletetextview in android. activity_main.xmlDrag the AutoCompleteTextView and TextView from the pallete, now the activity_main.xml file will like this: File: activity_main.xml
Activity classLet's write the code of AutoCompleteTextView. File: MainActivity.java
package example.TheDeveloperBlog.com.autocompletetextview; import android.graphics.Color; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.widget.ArrayAdapter; import android.widget.AutoCompleteTextView; public class MainActivity extends AppCompatActivity { String[] language ={"C","C++","Java",".NET","iPhone","Android","ASP.NET","PHP"}; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //Creating the instance of ArrayAdapter containing list of language names ArrayAdapter Output:
Next TopicAndroid ListView Example
|