I have a custom listview item like this:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:state_activated="true"
android:descendantFocusability="blocksDescendants"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/listicon_imageview"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="10dp"
android:scaleType="centerInside"
android:clickable="true"
android:src="@drawable/ic_launcher" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignTop="@+id/listicon_imageview"
android:layout_toRightOf="@+id/listicon_imageview"
android:text="Burnt offering"
android:textStyle="bold"
android:ellipsize="end"
android:singleLine="true"
android:textSize="16sp" />
</RelativeLayout>
</LinearLayout>
Then I am setting Mulitple choice selection:
getListView().setChoiceMode(AbsListView.CHOICE_MODE_MULTIPLE_MODAL);
In the bindItemViewHolder method of my CursorAdapter I set the Listener for the ImageView:
itemViewHolder.icon.setImageDrawable(drawable);
itemViewHolder.icon.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
int position = (int)view.getTag();
mListView.setItemChecked(position, !isPositionChecked(position));
}
});
Once the ImageView is clicked, the whole list item should highlight, whereas once the item iteself is clicked, some other Activity will be started. This is similar to the Gmail App, where the user clicks the icons to select for delete. This is what I need, too.
The problem is, however, I cannot get the item to highlight upon click on the ImageView (the cursor/list positions are correct). How can I get to see the highlight on my entire custom list item?