android - RecyclerView with nested RecyclerView - make nested RecyclerView clickable as a whole view -
i use recyclerview shows list of entries. each entry hosts recyclerview list of images.
i want make nested recyclerview clickable, not items of it, whole view.
how can achieve that?
problem:
- setting onclicklistener main view of nested recyclerview work, if click outside recyclerview itself
- clicking on nested recyclerview not hand on clicks parent view (i tried set clickable, focusable, focusableintouch false, still, touch not delegated consumed nested recyclerview...
here's view wrapping adapter:
<?xml version="1.0" encoding="utf-8"?> <android.support.v7.widget.cardview xmlns:android="http://schemas.android.com/apk/res/android" xmlns:card_view="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="wrap_content" card_view:cardcornerradius="0dp" android:layout_margin="5dp" android:foreground="?android:attr/selectableitembackground" > <relativelayout android:layout_width="match_parent" android:layout_height="wrap_content"> <relativelayout android:id="@+id/rltop" android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentleft="true" android:text="datum" android:textstyle="bold" android:id="@+id/tvdate" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentright="true" android:text="info" android:id="@+id/tvinfo" /> </relativelayout> <android.support.v7.widget.recyclerview android:id="@+id/rvdata" android:clickable="false" android:focusableintouchmode="false" android:focusable="false" android:layout_below="@+id/rltop" android:layout_width="match_parent" android:layout_height="68dp" android:scrollbars="horizontal" /> </relativelayout> </android.support.v7.widget.cardview>
in order entire row clickable , not every image u need implement custom onitemclicklistener (name comes listview , sorry). take @ link worked out me.
edit:
the nested recycler steals clicks. in order fix u need create cusom touch listener , pass nested recycler. 1 u put outer ercycler pass event outer.
edit 2:
add selector 2 states button entire row, @ onclick on inner recycler setselected(true) row , postdelay 50ms setselected(false) give "click" effect.
Comments
Post a Comment