views:

53

answers:

1

Hello,

Can someone tell me how to skip to a position in an alphabetically sorted ListView when given a char or string input from an onClick method?

For example, I have a dialog that passes back a char. If that char is a B I want the listview to skip to the first B entry.

Any help would be greatly appreciated.

Thanks, Josh

A: 

If your listview contains so many entries that this is necessary, wouldn't it be beneficial to simply remove all but the "b" entries? Thus your listview would automatically show the "b's" and only the "b's." It should be pretty easy to do that if you dump the entries into a list or array object.

I realize this doesn't directly answer your question, but sometimes it can be beneficial to get outside feedback on a design aspect.

Also, doesn't

myListview.Items(X).Selected = true;

where X is your first "b" item solve the problem?

The listView is for a media player, so while it would be possible to requery the array for only the letter selected, I worry that after the user chooses the letter they may want to scroll to another entry later.
Josh
The standard UI convention in android is to filter. You will see this in contacts, talk, and even in the music app. This is a lot more powerful because it allows you to filter on more than just the first letter; and of course it is generally good to be consistent with the user's expectation from other parts of the UI. You can see an example of how to do this in the platform's music picker: http://android.git.kernel.org/?p=platform/packages/apps/Music.git;a=blob;f=src/com/android/music/MusicPicker.java
hackbod
I understand the importance of maintaining the stock Android feel, and I am simply attempting to add functionality.
Josh
I have implemented SectionIndexer to my activity. Would it be simpler just have the input char send you to one of these sections? Can anyone help me with this code?
Josh
Any fresh thoughts on this? There has to be a way to move down a list line by line and check to see if a char matches the entry...
Josh