android edittext with drop down list -


i have edittext gets values user. want add option allows user choose different options via drop down list when edittext clicked. have idea how this?

this edittext code:

<edittext     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:inputtype="textpersonname"     android:ems="10"     android:id="@+id/dish_quantity"     android:layout_below="@+id/dish_name"     android:layout_alignparentright="true"     android:layout_alignparentend="true"     android:hint="quantity" /> 

i want this:

enter image description here

i think requirement:

just follow example: xml:-

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"     android:orientation="vertical"     android:layout_width="fill_parent"     android:layout_height="fill_parent"     >    <autocompletetextview     android:id="@+id/languages"     android:layout_width="fill_parent"     android:layout_height="wrap_content"></autocompletetextview> </linearlayout> 

activity:-

import android.app.activity; import android.os.bundle; import android.widget.arrayadapter; import android.widget.autocompletetextview;  public class mainactivity extends activity {      string[] languages = { "c","c++","java","c#","php","javascript","jquery","ajax","json" };      /** called when activity first created. */     @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.main);                 //create array adapter         arrayadapter<string> adapter = new arrayadapter<string>(this,android.r.layout.select_dialog_singlechoice, languages);                 //find textview control         autocompletetextview actextview = (autocompletetextview) findviewbyid(r.id.languages);         //set number of characters user must type before drop down list shown                 actextview.setthreshold(1);                 //set adapter         actextview.setadapter(adapter);     } } 

demo:-

enter image description here


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -