Simple hard-coded AutoCompleteTextView

suggest change

Design (layout XML):

<AutoCompleteTextView
   android:id="@+id/autoCompleteTextView1"
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
   android:layout_alignParentTop="true"
   android:layout_centerHorizontal="true"
   android:layout_marginTop="65dp"
   android:ems="10" />

Find the view in code after setContentView() (or its fragment or custom view equivalent):

final AutoCompleteTextView myAutoCompleteTextView = 
    (AutoCompleteTextView) findViewById(R.id.autoCompleteTextView1);

Provide hard-coded data via an adapter:

String[] countries = getResources().getStringArray(R.array.list_of_countries);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,countries);
myAutoCompleteTextView.setAdapter(adapter);

Tip: Though the preferred way would be to provide data via a Loader of some kind instead of a hard-coded list like this.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents