0


I've following requirement and Since I'm new to this Android stuff, I'm not able to figure it out.

I've two Edit text fields for a driverName and a vehicleNumber. But these values shouldn't be new i.e
When I try to enter driverName in particular EditText field, I should get all the driverNames populated so that I can choose one them. Same for vehicleNumber too.

For this I already have data of driverName and Vehicle Number But my problem is how to populate them while entering in fields ??? Any good answer will be appreciated :)
Thank You.

Kishore Kumar Korada
  • 1,204
  • 6
  • 22
  • 47
  • 1
    You should go with `AutoCompeteTextView`. Search on __Google__ you will find many solution. – M D Mar 22 '15 at 06:14

1 Answers1

1

You should go AutoCompleteTextView as What M D suggested. Example is

public class CountriesActivity extends Activity {
     protected void onCreate(Bundle icicle) {
         super.onCreate(icicle);
         setContentView(R.layout.countries);

         ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
                 android.R.layout.simple_dropdown_item_1line, COUNTRIES);
         AutoCompleteTextView textView = (AutoCompleteTextView)
                 findViewById(R.id.countries_list);
         textView.setAdapter(adapter);
     }

     private static final String[] COUNTRIES = new String[] {
         "Belgium", "France", "Italy", "Germany", "Spain"
     };
 }
Fahim
  • 12,198
  • 5
  • 39
  • 57