Android : Catching onClick events in child view of a list item

on Sunday, September 7, 2014


How can I catch onClick events in multiple child views of a list item in a ListFragment with custom Adapter?


I want the onClick event to return the item id and the child view id.


My list item layout is.



<?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="wrap_content">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:id="@+id/event_status" />

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="7dp"
android:nestedScrollingEnabled="false">

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/event_members" />

<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="@+id/event_date"/>
</LinearLayout>
</LinearLayout>


I want to catch clicks on event_status and event_members separately.


0 comments:

Post a Comment