I have a ListView with hundreds of rows sorted A to Z. I'd like to create a Composite Widget located on the right with TextViews labeled A to Z. Touching each TextView will filter the ListView and only display records that start with the letter of the TextView. For example, touching C will filter all rows and only display items that start with the letter C.
I could simply create 26 TextViews labeled A to Z, but I'd like to only create TextViews of letters of items in the ListView. That is, if there are no items that begin with X, then don't create an X TextView and create TextViews of letters of items in the ListView. If the items in the ListView are apple, banana and grape, then create three TextViews labled A, B and G.
Can Android support this? Is this a bad design? What do you recommend? Thanks in adv开发者_JS百科ance!
Can Android support this?
Sure.
Is this a bad design?
Yes. Your TextViews
will be too small to be tapped.
What do you recommend?
Use standard Android ListView
filtering. There are many more answers here on StackOverflow referencing the Filterable
interface.
精彩评论