开发者

dynamic header for list in android

dynamic header for list in android

some thing like the above image. I have a huge list of data being populated from the db in a list.

i have used index adapter to index the list through fastscroll, now i want to group them alphabetically

can any one give me any idea to do this.. i was looking all over the net but not able to find a good solution

ArrayList<String> list= new ArrayList<String>();
    MyIndexerAdapter<String> adapter = new MyIndexerAdapter<String>(
                        getApplicationContext(), android.R开发者_C百科.layout.simple_list_item_1,
                        list);
                lv.setAdapter(adapter); 


  • The GreenDroid library can achieve it

You can install the demo available in the Android Market and look at the Tweaked ItemVew part. The code is visible here.

http://lh6.ggpht.com/_OHO4y8YcQbs/TQFQTfazM2I/AAAAAAAAMpQ/lgPpIKImdZw/s288/gd5.png

  • There is also a more lightweight solution with the Mark Murphy's SectionedAdapter.


The way I achieved it is having an hidden textview in the row layout , then in getview I would check if the current row is the first row for the letter , if yes I would make the textview visible , else invisible ( reset reused layouts ).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜