android - what is wrong with this layout, double clicks -


i trying similar app list

enter image description here

but hard me, can't understand layout system, ended doing in recyclerview rectangular , imagebuttons in left , 2 on right. buttons have functions. if click star add/remove favorites, download button download it, , right buttons delete , update.

enter image description here

i added function clicklistener using code google

public class recycleritemclicklistener implements recyclerview.onitemtouchlistener {     private onitemclicklistener mlistener;      public interface onitemclicklistener {         public void onitemclick(view view, int position);     }      gesturedetector mgesturedetector;      public recycleritemclicklistener(context context, onitemclicklistener listener) {         mlistener = listener;         mgesturedetector = new gesturedetector(context, new gesturedetector.simpleongesturelistener() {             @override             public boolean onsingletapup(motionevent e) {                 return true;             }         });     }      @override     public boolean onintercepttouchevent(recyclerview view, motionevent e) {         view childview = view.findchildviewunder(e.getx(), e.gety());         if (childview != null && mlistener != null && mgesturedetector.ontouchevent(e)) {             mlistener.onitemclick(childview, view.getchildposition(childview));         }         return false;     }      @override     public void ontouchevent(recyclerview view, motionevent motionevent) {     } } 

and linked listener doing this:

 mrecyclerview.addonitemtouchlistener(                 new recycleritemclicklistener(this, new recycleritemclicklistener.onitemclicklistener() {                     @override public void onitemclick(view view, int position) {                         context context = getapplicationcontext();                         int duration = toast.length_short;                         charsequence text = "item clicked";                         toast toast = toast.maketext(context, text, duration);                         toast.show();                      } 

it show item clicked when click on imagebutton(i setted function it), both actions called...

how can make separete clicks?

but think main problem .xml, can , see wrong, please? added lot of relatives, 1 border, background, , third has items inside =x.

here's item_list recycler.

<?xml version="1.0" encoding="utf-8"?>  <relativelayout     xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"     android:paddingtop="10dp"     >     <relativelayout         android:layout_width="match_parent"         android:layout_height="match_parent"         android:background="@drawable/border"         android:padding="1dp"         >      <relativelayout xmlns:android="http://schemas.android.com/apk/res/android"     android:layout_width="match_parent"     android:layout_height="match_parent"      android:baselinealigned="false"     android:padding="5dp"     android:background="@android:color/white"     android:weightsum="1"       >      <linearlayout android:id="@+id/thumbnail"          android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:padding="5dip"         android:layout_alignparentleft="true"         android:background="@android:color/white"          android:layout_marginright="5dip">          <imagebutton             android:id="@+id/status"             android:background="@android:color/white"               android:layout_width="25dip"             android:layout_height="25dip"              />      </linearlayout>       <textview         android:id="@+id/titulo"         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:layout_aligntop="@+id/thumbnail"         android:layout_torightof="@+id/thumbnail"         android:textcolor="#040404"         android:typeface="sans"         android:background="@android:color/white"            android:textsize="15dip"         android:textstyle="bold"/>      <textview         android:id="@+id/descricao"         android:layout_width="fill_parent"         android:layout_height="wrap_content"         android:textcolor="#343434"         android:textsize="10dip"         android:layout_torightof="@+id/thumbnail"         android:background="@android:color/white"            android:layout_below="@+id/titulo" />        <imagebutton         android:layout_width="wrap_content"         android:layout_height="wrap_content"         android:background="@android:color/white"           android:paddingright="10dp"         android:id="@+id/delete"         android:layout_toleftof="@+id/update"         android:padding="5dip"          android:onclick="deletarlei" />      <imagebutton android:layout_width="wrap_content"         android:id="@+id/update"         android:layout_height="wrap_content"         android:background="@android:color/white"          android:padding="5dip"          android:layout_alignparentright="true"          />   </relativelayout>     </relativelayout>     </relativelayout> 

when have similar problems, tag on top viewgroup in layout solves problem. in case top viewgroup in each cell/row.

android:descendantfocusability="beforedescendants"

you can try setting on recyclerview. there 3 options, remember beforedescendants should work, otherwise give other 2 try.

i think can put onclicklistener on image in adapter , onitemclicklistener on recycle view. not clear code you're doing.


Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -