AutoCompleteTextView might help you try it out here
how to show possible matching suggestions for text being typed in an edittext?
-
29-05-2022 - |
Question
i'm creating an Application
where there is a part where user needs to enter the state
,city
and district
in an Edittext
.
while entering the state
I need to show some possibly matching suggestions with the letters that are typed in the edittext
.
I have searched a lot and couldnt find anything useful as per my requirements..
So how do i go about this?? the suggestions of can come from a sqlite database table... if anybody knows any good example or can guide me through the coding please help... i have no idea how to do it...
Solution 2
OTHER TIPS
use autocomplete textview and then get your country/state list and set in adapter.
public class CountriesActivity extends Activity {
protected void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.countries);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,
android.R.layout.simple_dropdown_item_1line, COUNTRIES);
AutoCompleteTextView textView = (AutoCompleteTextView)
findViewById(R.id.countries_list);
textView.setAdapter(adapter);
}
private static final String[] COUNTRIES = new String[] {
"Belgium", "France", "Italy", "Germany", "Spain"
};
}
setThreshold(int threshold)
Specifies the minimum number of characters the user has to type in the edit box before the drop down list is shown.