Android List Item with Image View not clickable -


i have list item imageview's, textview's. issue list item whole not clickable, it's when click on of imageview it's clickable. have set android:descendantfocusability="blocksdescendants" root , below each child

android:focusable="false" android:focusableintouchmode="false" 

still imageviews clickable. below list item xml

<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://splashurl.com/m22ydvb     android:id="@+id/itemdisplaylist_layout"     android:layout_width="match_parent"     android:layout_height="wrap_content"     android:descendantfocusability="blocksdescendants"     android:minheight="@dimen/loclist_item_minumum_height"     android:orientation="horizontal"     android:weightsum="1" >      <imageview         android:id="@+id/listitem_pic"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_gravity="center"         android:layout_weight="0.2"         android:contentdescription="@null"         android:focusable="false"         android:focusableintouchmode="false" />      <linearlayout         android:layout_width="0dp"         android:layout_height="match_parent"         android:layout_weight="0.7"         android:descendantfocusability="blocksdescendants"         android:orientation="vertical"         android:weightsum="1" >          <textview             android:id="@+id/listitem_name"             android:layout_width="match_parent"             android:layout_height="0dp"             android:layout_weight="0.3"             android:focusable="false"             android:focusableintouchmode="false"             android:textcolor="@color/loclistitem_text"             android:textisselectable="true" >         </textview>          <textview             android:id="@+id/listitem_address"             android:layout_width="match_parent"             android:layout_height="0dp"             android:layout_weight="0.5"             android:focusable="false"             android:focusableintouchmode="false"             android:textisselectable="true" >         </textview>          <linearlayout             android:layout_width="match_parent"             android:layout_height="0dp"             android:layout_weight="0.2"             android:descendantfocusability="blocksdescendants"             android:orientation="horizontal" >              <textview                 android:id="@+id/listitem_text2"                 android:layout_width="0dp"                 android:layout_height="match_parent"                 android:layout_weight="0.4"                 android:focusable="false"                 android:focusableintouchmode="false"                 android:textcolor="@color/loclistitem_text"                 android:textisselectable="true" />              <imageview                 android:id="@+id/listitem_prop1"                 android:layout_width="0dp"                 android:layout_height="match_parent"                 android:layout_weight="0.2"                 android:contentdescription="@null"                 android:focusable="false"                 android:focusableintouchmode="false" />              <imageview                 android:id="@+id/listitem_prop2"                 android:layout_width="0dp"                 android:layout_height="match_parent"                 android:layout_weight="0.2"                 android:contentdescription="@null"                 android:focusable="false"                 android:focusableintouchmode="false" />              <imageview                 android:id="@+id/listitem_prop3"                 android:layout_width="0dp"                 android:layout_height="match_parent"                 android:layout_weight="0.2"                 android:contentdescription="@null"                 android:focusable="false"                 android:focusableintouchmode="false" />         </linearlayout>     </linearlayout>      <imageview         android:id="@+id/listitem_img3"         android:layout_width="0dp"         android:layout_height="wrap_content"         android:layout_weight="0.1"         android:contentdescription="@null"         android:focusable="false"         android:focusableintouchmode="false"          android:clickable="false"/>  </linearlayout> 

i not sure going wrong struggling last 6 hours.

custom adapter code(partial coe):

layoutinflater inflater = (layoutinflater) context                 .getsystemservice(context.layout_inflater_service);         if (convertview == null) {             holder = new viewholder();              convertview = inflater.inflate(r.layout.list_listitem, parent,false);              holder.locname = (textview) convertview                     .findviewbyid(r.id.listitem_name);             holder.locdistance = (textview) convertview                     .findviewbyid(r.id.listitem_text2);              holder.locrating = (imageview) convertview                     .findviewbyid(r.id.listitem_img3);              convertview.settag(holder);         } else {              holder = (viewholder) convertview.gettag();          }         convertview.setonclicklistener(this);          holder.locname.settext(data.get(position).getlocationname());          return convertview; 

please advise.

solution 

finally able using relative layout instead of linear layout in list item layout.

add click listener when inflate view only. try this:

convertview = inflater.inflate(r.layout.list_listitem, null);  convertview.setonclicklistener(new onclicklistener() {                  @override                 public void onclick(view v) {                    }              });   convertview.settag(holder); 

Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -