applidium / HeaderListView

Android ListView with sticky headers
http://applidium.com/en/news/headerlistview_for_android/
Other
313 stars 96 forks source link

onRowItemClick(...) not called #4

Closed sebastiansieber closed 11 years ago

sebastiansieber commented 11 years ago

Thanks for your fantastic work, I do enjoy working with HeaderListView a lot. Nevertheless I have one problem related to click events.

I implemented the onRowItemClick(...) method in my Section Adapter. Unfortunately it is not called and I don't know why. Do I need to "attach" it to the HeaderListView?

Please let me know if you need further information.

It would be very helpful if you would include an example for this in the HeaderListViewDemo.

Thank you & best regards, Sebastian

sebastiansieber commented 11 years ago

Add the following on line 50 of HeaderListView.java and it works:

mListView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { if (mAdapter != null) mAdapter.onItemClick(parent, view, position, id); } });

via http://stackoverflow.com/users/657503/lauw

tokou commented 11 years ago

Thanks a lot for your comment. Indeed I just forgot to set and OnItemClickListener to the HeaderListView. This is now fixed.

ggeetha commented 7 years ago

I like the work what given here. One issue i am facing here is that, onRowItemclick(..) is not functioning. I am using the latest code base from the github. Eventhough getting the same issue. Pls help me to resolve.

ggeetha commented 7 years ago

I found the solution. Actual cause is the setOnItemClickListener in HeaderListView is not functioning properly. For that this solution worked for me.

I just found solution from here.. but by deep clicking...

If any row item of list contains focusable or clickable view then OnItemClickListener won't work.

The row item must have a param like android:descendantFocusability="blocksDescendants".

here you can see example, how your list item should look like. Your list item xml should be... row_item.xml (your_xml_file.xml)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:baselineAligned="false"
android:descendantFocusability="blocksDescendants"
android:gravity="center_vertical" >

// your other widgets here

</LinearLayout>
ggeetha commented 7 years ago

http://stackoverflow.com/a/14372750/5363625

mortenholmgaard commented 6 years ago

This is actually a better solution for the problem: https://stackoverflow.com/a/16404545/860488