3

I know how to display it in the screen, but when I use the Contacts app in my phone, I found its alphabet section header can be fixed in the top when I scroll the list.

How to make that happen?

PeeHaa
  • 69,318
  • 57
  • 185
  • 258
virsir
  • 14,799
  • 23
  • 73
  • 108

2 Answers2

1

See the AmazingListView here, which is ListView with section headers.

It works similarly to the default Contacts application.

http://code.google.com/p/android-amazing-listview/

Randy Sugianto 'Yuku'
  • 68,307
  • 56
  • 174
  • 223
  • Thanks for the pointer. That helped. I made it work for my project but I want to hide the header of the first row. I can change the colour by writing `view.findViewById(R.id.header).setBackgroundColor(Color.RED)` in `bindSectionHeader` but can not hide the header with `view.findViewById(R.id.header).setVisibility(View.GONE);` Any help? :( – Sufian May 01 '13 at 11:18
  • One interesting thing is that after executing the line `view.findViewById(R.id.header).setVisibility(View.GONE);`, the header is not occupying space but still visible. Still need some help. :| – Sufian May 01 '13 at 11:34
0

You need to implements

public int getSectionForPosition(int position) {
return <return position where header start>
}

If you are using AlphaIndexer you can simply use

public int getSectionForPosition(int position) {
return alphaIndexer.getSectionForPosition(position);
}

Hope that helps.

vsm
  • 3,375
  • 2
  • 24
  • 36