user3364963
user3364963

Reputation: 397

List View With Section Headers

I have a working list view with base adapter.

I have implemented list view with section headers based on this tutorial by Cyril Mottier (2011). Please look at Method #2: Leverage GONE visibility.

http://cyrilmottier.com/2011/07/05/listview-tips-tricks-2-section-your-listview/

So each row of the list view has a text view that is revealed based on some logic to determine if its a section header.

The problem I am having is on the row which contains an item and section header clicking on the section header is the same as clicking on the row.

I only want the item to be clickable if that is possible.

Diagram

________________________ROW__________________________

------------TextView (SECTION HEADER)------------

------------TextView (SOME ITEM)----------------------

________________________ROW__________________________

I do not want clicking on TextView Section Header to be the same as clicking the entire row. Only clicking on textView some item can do it but I still wish to use the onItemClickListener. Is there a way to do this? Thank you in advance.

UPDATE Solution: as described by user Coeffect Added this in my getView method of the base adapter sub class

holder.tvSection.setOnClickListener(null);

Upvotes: 0

Views: 597

Answers (1)

Coeffect
Coeffect

Reputation: 8866

Two things that might work:

  1. Set the section header TextView to not be clickable (clickable=false) in the XML.
  2. Add a click listener to the section header that doesn't do anything

Upvotes: 1

Related Questions