Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Implement a list with section divider in android

Hi how can i implement a list with section divider like the one on android's building blocks lists

enter image description here

Can you point any articles or tutorials to achieve this?

like image 497
Hannoun Yassir Avatar asked Nov 22 '12 18:11

Hannoun Yassir


3 Answers

I implemented a possible version here:

http://steprobe.wordpress.com/2013/03/29/google-building-blocks-style-listview-for-android/

like image 137
steprobe Avatar answered Oct 27 '22 18:10

steprobe


There are many tutorials to get grouped lists. The trick is to look for "adapter" and not "list". For instance, this one: http://android.cyrilmottier.com/?p=440

like image 22
Jorge Avatar answered Oct 27 '22 16:10

Jorge


Each row in your list can be totally separated in terms of layout from others. So if you got 3 rows on your list, you can have each one can look totally different. You need to write your own adapter (i.e. extending ArrayAdapter), override getView(), getViewTypeCount() and getItemViewType(). Then for each row your getView() shall do any logic you want, inflate any layout you want and return that View to the list.

like image 22
Marcin Orlowski Avatar answered Oct 27 '22 17:10

Marcin Orlowski