I read about the problems that onClickListener will consume onItemClickListener Events, for example here or here . My problem is quite another:
I have a CustomAdapter extends the ArrayAdapter where I place model objects to create a string. In My Activity, I registered onItemClickListener, e.g.
//items can focus false to try to get the onItemClick-event mListView.setItemsCanFocus(false); mListView.setOnItemClickListener(this); mListView.setAdapter(this.favoritePointAdapter);
then in my Adapter.getView () method I inflate my layout, get my ImageView and register OnClickListener on it, like this
@Override public View getView(int position, View convertView, ViewGroup parent){
at least I will try to extract these events in my adapter, for example,
@Override public void onClick(View v) { Log.d("ListAdapter", "onClick triggered"); //never triggered switch (v.getId()) { case R.id.list_row_favorite_point_click_area: Log.d("ListAdapter", "onClick id->list_row_favorite_point_click_area"); //never triggered break; default: break; } }
If you found the xml RowView interesting, here it is:
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/list_row_relative_parent" android:layout_width="fill_parent" android:layout_height="wrap_content" android:orientation="horizontal" android:focusable="false"> <LinearLayout android:id="@+id/list_row_icon" android:layout_width="30dip" android:layout_height="30dip" android:layout_gravity="center_vertical" android:layout_margin="3dip" /> <LinearLayout android:layout_weight="50" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="vertical" android:layout_gravity="center_vertical"> <TextView android:id="@+id/list_row_name" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#333333" android:text="defaultText" android:textStyle="bold" /> <TextView android:id="@+id/list_row_region" android:layout_width="fill_parent" android:layout_height="wrap_content" android:textColor="#999999" android:textStyle="italic" android:text="Region" /> </LinearLayout> <LinearLayout android:id="@+id/list_row_favorite_point_click_area" android:layout_width="50dip" android:layout_height="50dip"> <ImageView android:id="@+id/list_row_favorite_icon" android:layout_width="20dip" android:layout_height="20dip" android:layout_gravity="center_vertical" android:layout_weight="0.1"> </ImageView> </LinearLayout> </LinearLayout>
As I said, the ListView onItemClick from My Activity fires until I never reach onClick inside my adapter. I think that onItemClick "feels" the responsibility for the entire series and consumes TouchEvents. What can I do to get around this?
Note. I tried setItemsCanFocus (false) and configured in my root directory also to false, as indicated in other questions.