0

I want to have a text field that that let the user to enter a country name, and as it enter the name it automatically gives options. something like Google search, that predicts based on entered letters. But in my case it should show country names. I know I have to use AutoCompleteTextField but do not know how to add countries' name.

Any idea?

user2977338
  • 135
  • 3
  • 5
  • 11
  • Seem somebody already made for you ! Check it => http://stackoverflow.com/questions/6788013/android-string-array-with-all-countries-in-different-languages – Thein Nov 11 '13 at 03:39

2 Answers2

0

You might want to have a look at this thread:

How to set Adapter to Auto Complete Text view?

and just replace the list of months with your list of countries.

Community
  • 1
  • 1
dkgeld
  • 33
  • 1
  • 6
  • Thanks for your post. It seems a good solution, but as u know the list of countries is really long, almost 200. Is it possible to put all names in a txt file and then attach that ? – user2977338 Nov 11 '13 at 00:09
0

Create a collection on countrys.xml file res/values/country.xml:

<resources>
<string-array name="country_items">
    <item>USA</item>
    <item>UK</item>
    <item>Japan</item>
</string-array>
</resources>

In your Activity...

String[] Country = this.getResources().getStringArray(R.array.country_items);
TheATeam
  • 26
  • 2