1

still pretty new to android

I have to clone an iphone application. Im having problems with figuring out the best way to approach how to clone this element :

enter image description here

Its a text box where you can type in limited amount of chars. When you press on it the list should show last five elements that you have entered (not autocomplete) so that when you click on them they are entered to text box.

How would you approach this? which class would be best to extend (I know storing could be done through shared preferences)

Thanks

AndroidGecko
  • 14,034
  • 3
  • 35
  • 49
  • my current thinking is that I could get the history through shared preferences then load it to adapter and connect it to AutoCompleteTextView.. then the challenge is to somehow set the threshold to 0 (or achieve that in some other way) so that all the answers are there as soon as focus is set – AndroidGecko Feb 06 '12 at 09:22
  • this is useful http://stackoverflow.com/questions/2126717/android-autocompletetextview-show-suggestions-when-no-text-entered – AndroidGecko Feb 06 '12 at 09:29

2 Answers2

0

Do This:

AutoCompleteTextView textView = (AutoCompleteTextView)findViewById(R.id.autocomplete_country);
// Get the string array
String[] countries = getResources().getStringArray(R.array.countries_array);
// Create the adapter and set it to the AutoCompleteTextView 
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, countries);

textView.setAdapter(adapter);
0

create an AutoCompleteTextView just as in this example

stackoverflow.com/questions/2126717/

store history in SharedPreferences

AndroidGecko
  • 14,034
  • 3
  • 35
  • 49