forum

home / developersection / forums / how to detect click event at empty space of gridview inside linearlayout in android?

How to detect click event at empty space of gridview inside linearlayout in android?

Norman Reedus 4069 19-Nov-2014

I have a following problem. I have a GridView inside LinearLayout as image below. I want to detect click event when user click at empty space of GridView, in the image, the location that I want is the red area and also inside the green area.

But I have following problems.

  1. If I add onClickListener for GridView: error because Adapter cannot add click event.
  2. If I add onItemClickListener for GridView: I just can detect where exist items (in the image is the white box)
  3. If I add onClickListener for LinearLayout I just can detect click event on green area, not red area.

So how can I fix above problem.

@Edit: my layout looks like:

<LinearLayout>

  <GridView

    android:layout_width="fill_parent"

    android:layout_height="fill_parent"/>

</LinearLayout>


Updated on 19-Nov-2014

Can you answer this question?


Answer

1 Answers

Liked By