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
  • 71,436
  • 58
  • 190
  • 262
virsir
  • 15,159
  • 25
  • 75
  • 109

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'
  • 71,383
  • 57
  • 178
  • 228
  • 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,373
  • 2
  • 25
  • 36