Rakesh Gondaliya Rakesh Gondaliya - 14 days ago 5
Android Question

Set position of listview based on input in EditText Android

I am making an dictionary application where i intend to have many words.(around 1 Lakh)
I am rendering it in a list along with the meaning of the Word.

I am using the custom array adapter to fill in the listView and inflating the custom layout in listview.

Here is my scenarion :

1> I have edittext which allows user to enter the words which they are looking for.
2> Once user type word , for example R , i want to set Selction of the list view, where first letter is R , And once user type next work , lets say RE , the list view position should be changed to the list position where first two letters are RE .

To implement this i have added addTextchanged Listner to the edittext and filtered the adapter but it is not working. Once i type something list getting empty.

Can you please suggest me better approach or how can i implement following functionality.

Any help would highly appreciated.

Thanks a lot.

Jul Jul
Answer

Here is two suggestion for you.
1, Use Search Interface with Content Provider. This way is a little bit complex but more effective for manager large data. This Dictionary sample provides two searching option
- Type keyword and suggestion listview dropdown with match items. You just click and get meaning of word
- Type not complete keyword and press magnifier icon an it return relative match items listview.

You can download sample and import or just Create a sample project in Eclipse and choose SearchableDictionary example.

2, Stick to Edittext and filter ListView. Add your code so we can help you out.

In my opinion AutoCompleteTextView with a ListView below is not convenience for User. You had suggested dropdown listview (in AutoCompleteTextView), user expect to get word's meaning when they click suggestion not click again in ListView below (two clicks to get word's meaning). An AutoCompleteTextView with TextView display word meaning seem suitable.

Comments