2

I want to set autoCompleteTextView in my android application and it display all the places when I enter character in the autoCompleteTextView like Google map . How can I add that type of autoCompleteTextView in my app. I am currently use this code:

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


    private static final String[] COUNTRIES = new String[] {
     "Belgium", "France", "Italy", "Germany", "Spain"
 };

But is display the places in the string array.

please give me a solution ..

TamiL
  • 2,706
  • 4
  • 24
  • 44
  • when I try this code:[link](http://stackoverflow.com/questions/6489645/android-how-to-make-autocompletetextview-work-as-google-search-box) Get error "requires unavailable shared library com.android.maps; falling" What is the reason? – TamiL Oct 24 '12 at 06:49

1 Answers1

0
 autoCompleteTextView=findViewById(R.id.autoCompleteTextViewID);
employeeNames  = new ArrayList<String>();

// getdata & store in dataList

dataAdapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_item, employeeNames );
dataAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
autoCompleteTextView.setThreshold(1);
autoCompleteTextView.setAdapter(dataAdapter);

autoCompleteTextView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    @Override
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

        String selectedStr  = parent.getItemAtPosition(position).toString();

    }
});
TejpalBh
  • 427
  • 4
  • 13