RecyclerView with nested RecyclerView - make nested RecyclerView clickable as a whole view

I use a RecyclerView that shows a list of entries. Each entry hosts another RecyclerView that is a list of images.

I now want to make this nested RecyclerView clickable, not the items of it, but the whole view.

How can I achieve that?

Problem:

  • setting the onClickListener for the main view of the nested RecyclerView does work, but only if I click outside the RecyclerView itself
  • clicking on the nested RecyclerView does not hand on the clicks to the parent view (I even tried to set clickable, focusable, focusableIntouch to false, still, the touch is not delegated but consumed by the nested RecyclerView...

Here's the view for the 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>

--------------Solutions-------------

In order to do the entire row clickable and not every image u need to implement a custom onItemClickListener (name comes from listview , sorry). Take a look at this link this worked out perfectly for me.

Edit:

The nested recycler steals your clicks. in order to fix that u will need to create a cusom touch listener and pass it to the nested recycler. Just like the one that u put to the outer ercycler but pass the event to the outer.

Edit 2:

Add a selector with two states just like a button to the entire row, then at the onclick on the inner recycler setSelected(true) the row and postDelay with 50ms for setSelected(false) this will give the "click" effect.

Category:android Time:2018-10-30 Views:1

Related post

  • How to make the Image to Occupy the whole view in Android 2011-04-11

    I am trying to display an image using a canvas in a view. I could not able to make the image to be appear through out the view.(i.e) The image does n't occupy the entire portion of the view, instead it occupies only the specified part of the view. An

  • Using the recyclerview with a database 2014-10-22

    Currently there is no default implementation of RecyclerView.Adapter available. May be with the official release, Google will add it. Since there is no support for CursorAdapter with the recyclerview currently, how can we use a recyclerview with a da

  • Search filter on RecyclerView with Cards. Is it even possible? 2016-01-21

    As the title describes I want to add a search filter on RecyclerView with Cards in it. I've been searching for a couple of days but couldn't find anything. I keep getting filter on ListView and SearchView on RecyclerView separately but I wish to comb

  • Make the RecyclerView load more items from database 2018-06-18

    I am using recyclerview with cursors with the following set up, a RecyclerView with this adapter CursorRecyclerViewAdapter. Basically the items have an image and some TextViews. The RecyclerView is not going to have more than 5-7 items at max. My que

  • How to do a PHP nested class or nested methods? 2009-02-10

    How can I do this in PHP $myDBClass->users()->limit(5);//output you limited users to 5 $myDBClass->comments()->limit(3);//output you limited comments to 3 what I meant is nested methods or nested class (I don't know!) so when I call the l

  • Android: In Gridview how do I make the images clickable 2010-08-07

    I am trying to make the images clickable so that when they are pressed it will send the user to another page or link. How can I achive this? Currently each row in the GridView has 2 Buttons. How will it know which item in the GridView is clicked so t

  • Make an image clickable 2010-08-09

    I'm kind of new to this whole thing so I need some help. I have an application that creates an ImageView OnCreate. I want to make this image clickable and have it open a browser to a specific link. How would I do this? I'm having trouble specifically

  • How to make my widget clickable? 2011-02-01

    My widget is just a battery monitor. But i want to open a full screen activity with more info. here is the AndroidBatteryWidgetProvider.java: package cogiloo.widget; import android.app.PendingIntent; import android.appwidget.AppWidgetManager; import

  • how to make my image clickable 2012-02-28

    Obviously I missunderstood UIImageView vs UIImage, in order to register gesture(such as tap/click) on image, i need to have image in uiimageview and register gesture on uiimageview not on uiimage. So this piece of code works for me : - (void)drawRect

  • how to make a word in a complete text view clickable android(not url link) 2012-02-29

    Although I know there are hundreds of posts in stackoverflow regarding this post still, I did not found my appropriate answer. So I am asking it as new question. Problem:- I have a text in text view "You need cookies or banana to eat?" I want that if

  • How to make a HorizontalFieldManager clickable in BlackBerry? 2012-04-06

    I'm developing an application in BlackBerry and I have many HorizontalFieldManagers filled with components like shown in the image below: And I have to add many HorizontalFieldManagers like these within a for loop which are dynamically populated. Whe

  • How to make each bar clickable in a graph in perl 2012-04-17

    I have generated a graph. On click of each bar in the graph, I should be able to generate another graph. I am using GD::Graph module. If its not possible to make the bars clickable, is there a way where I can click the x-axis values at least? Thank y

  • Nested IF or nested CASE SELECT 2012-10-21

    Hi, No particular problem to solve just a general question. Is there any advantage in using nested IF or nested CASE SELECT statements to test for a series of conditions? I realise that there is a limit to the number of nested IFs that are permissabl

  • What is your experience with non-recursive make? 2009-02-17

    A few years ago, I read the Recursive Make Considered Harmful paper and implemented the idea in my own build process. Recently, I read another article with ideas about how to implement non-recursive make. So I have a few data points that non-recursiv

  • Traversing a nested LINQ query in of anonymous objects in C# view via ASP.NET MVC 2010-01-27

    Traversing a nested LINQ query in of anonymous objects in C# view via ASP.NET MVC Hi, done a lot of searching and reading but still require some specific information. I have the following code: List<DateTime> range = getRangeCollection(); var r

  • Make a ViewGroup clickable on Android 2010-07-14

    I have a ViewGroup (LinearLayout) which contains a couple of TextViews and one ImageView. I want to make this entire group clickable. I tried something like this: viewGroup.setOnClickListener( new OnClickListener(){ @Override public void onClick() {

  • How to use border-radius.htc with IE to make rounded corners 2010-11-02

    How to use border-radius.htc with IE to make rounded corners I am using border-radius.htc to fix border-radius in IE It is works very well here http://www.faressoft.org/eshterakat/border-radius/border-radius.html But it doesn't work in my html page !

  • Eclipse Console - what are the rules that make stack traces clickable? 2011-03-08

    I log quite a bit of stuff, and have noticed that Eclipse Console makes Java stacktraces clickable. The exception is highlighted (goes to the "Create Breakpoint" dialog box) and the filename + numbers are highlighted too (allows going straight to tha

  • does rewriting memcpy/memcmp/- with SIMD instructions make sense 2011-03-16

    Does rewriting memcpy/memcmp/... with SIMD instructions make sense in a large scale software? If so, why gcc doesn't generate simd instructions for these library functions by default. Also, are there any other functions can be possibly improved by SI

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.343 (s). 13 q(s)