0

I have a recycler view of cardviews, where each cardview contains a textview and a listview. I want the entire cardview to be one clickable item. Currently, if I click on the textview portion of the cardview it works, but clicking on the list portion does nothing. The listview appears to be stealing focus from the parent cardview.

DANGERZONE94
  • 139
  • 1
  • 9
  • possible duplicate of [Android-L CardView Visual Touch Feedback](http://stackoverflow.com/questions/24475150/android-l-cardview-visual-touch-feedback) – Daniel Nugent Sep 18 '15 at 17:56
  • I have already included what the answer there suggests. The cardview I have is clickable, just that the listview seems to be stealing focus and making that portion of cardview not clickable – DANGERZONE94 Sep 18 '15 at 17:58

2 Answers2

0

I think you can try to define following attribute in your cardview. I'm not sure it will work, I do not know why in some cases it solved the problem for me, on others not...

android:descendantFocusability="blocksDescendants"
gbaccetta
  • 4,449
  • 2
  • 20
  • 30
0

Just a thought if more elegant solutions could not be found: you may try overriding onInterceptTouchEvent() for the cardview and use a gesture detector which listens for a tap up on the motion event intercepted. Return true if the gesture is detected, such that the MotionEvent is intercepted and not passed on to its children, including the listview.

This way the cardview could see the click event before the listview.

headuck
  • 2,763
  • 16
  • 19