sergejsha / pinned-section-listview

Easy to use ListView with pinned sections for Android.
2.59k stars 808 forks source link

how to add onItemClick for non- section items in the list? #49

Closed hongzhou85 closed 10 years ago

hongzhou85 commented 10 years ago

PinnedSectionListView pList = (PinnedSectionListView) v.findViewById(R.id.pinned_list); pList.setOnItemClickListener( ... );

Only Section is detected and items (non-section) are not detected.

zorroyueng commented 10 years ago

When you dispatch the onClick , you should distinguish the Section and the Item, like this:

public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (itemList.get(position).getType() == Item.ITEM) {
 //  do your want to do...
}else{
  // the Section is on click 
}
sergejsha commented 10 years ago

See example app. Every item there is clickable.