0

I'm having a problem with a OnClickListener on a Relative Layout. The Relative Layout has a GridView inside, and I'm not able to make the clicks pass through the GridView.

What I would like to achieve is that the whole Relative Layout is responsive to clicks. Without the GridView it obviously works like a charm. But if I add the GridView with some elements, the whole area of the GridView becomes unresponsive. Only above the GridView it remains responsive.

So I tried everything: setting the GridView to don't allow touch, to be not clickable to pass it to the ParentView, but without any result.

Does anybody of you have an idea what I could try ?

Thanks a lot for any help! Cheers

Fábio Santos
  • 199
  • 1
  • 2
  • 16
Patric
  • 342
  • 4
  • 19
  • have u tried disabling the gridView? `setEnabled(false);` With that it should not respond to clicks – eduyayo May 13 '15 at 10:41
  • Did u try Onitem click listener on gridview to perform the same operation like on the relative layout. – Ravindra Kushwaha May 13 '15 at 10:43
  • Thank you guys! I did already try setEnabled(false); that doesn't work. Only setting it's visibility to GONE would work... I could try to workaround with the OnItemClick but, that's gonna be a terrible implementation as I have 10 of these relative layouts inside my activity with different tags, and handle that would just be quite ugly... That is the last solution I would like to implement. – Patric May 13 '15 at 12:10

1 Answers1

0

For GridView you are using an adapter and you have to use gridView.setOnItemClickListener() to make items clickable.

Exigente05
  • 2,161
  • 3
  • 22
  • 42
  • I do not want clickable Items. I want to pass the clicks to the parent View. The grid view should not be clickable at all. – Patric May 15 '15 at 11:48
  • Define a method and call it from Relative Layout onClick and GridView onItemClick- It will work. BTW, I faced same problem few months ago, got this solution, accepted the solution and worked. Let me add something, because of using adapter I had to use that and didn't get any better solution. Here is the link of that question http://stackoverflow.com/questions/27836019/how-to-make-every-content-of-a-relative-layout-clickable-in-android – Exigente05 May 15 '15 at 12:35