re => strings.xml
<resources> <string name="app_name">007</string> <string-array name="city_names"> <item>Rasht</item> <item>Tehran</item> <item>Karaj</item> <item>Tabriz</item> <item>Mashad</item> <item>Sari</item> <item>Shiraz</item> <item>Ahvaz</item> </string-array> </resources>
MainActivity.java
AutoCompleteTextView autoCompleteTextViewCities; String[] cities; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); autoCompleteTextViewCities= (AutoCompleteTextView) findViewById(R.id.autoCompleteTextViewCities); cities=getResources().getStringArray(R.array.city_names); ArrayAdapter<String> arrayAdapterCities=new ArrayAdapter<>(this, android.R.layout.simple_list_item_1,cities); autoCompleteTextViewCities.setAdapter(arrayAdapterCities); }
References
https://www.youtube.com/watch?v=dEhE9MMR7mg&list=PLshdtb5UWjSp0879mLeCsDQN6L73XBZTk&index=12https://github.com/mhdr/AndroidSamples/tree/master/007