0

I have an empty gridview that fills a column in a tablelayout, I want to longpress that gridview and shou a quickaction popup.

The empty gridview does not fire longpress event.

gridTue.setOnLongClickListener(new OnLongClickListener() {

    @Override
    public boolean onLongClick(View v) {
        // TODO Auto-generated method stub
        return false; //I've breackpoint this line to test if it fires or not
    }
});

XML:

<GridView
            android:id="@+id/gridTue"
            android:numColumns="1"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent"
            android:gravity="center"
            android:longClickable="true"
            android:background="@android:color/background_light" />
slybloty
  • 6,346
  • 6
  • 49
  • 70
  • Could you please provide us with the rest of the code, like where and how you inflate the view? – Heskja Oct 30 '12 at 17:16
  • are you sure you are clicking on the actual grid view ? (see the actual size of it with hierarchyviewer) also do you have any thing that tampers with touch events ? – njzk2 Oct 30 '12 at 17:21
  • do you want to longclick on the whole gridview or just an item? – chossen-addict Nov 26 '12 at 12:59

3 Answers3

4

in case you wish to long click an item on the gridView, you should use setOnItemLongClickListener .

if you wish to be able to long click the gridView itself, your code seems ok. maybe you've added some views inside it that catch the event? if so, you could use setOnTouchListener, or put the gridView in a layout that will catch this event.

android developer
  • 114,585
  • 152
  • 739
  • 1,270
0

maybe your gridView is in a ListView and then the events has handles by the listview and not by the gridview.

Eliel Haouzi
  • 607
  • 1
  • 6
  • 17
0

setOnItemLongClickListener worked for me instead of setOnLongClickListener as said above post.

Saghir A. Khatri
  • 3,429
  • 6
  • 45
  • 76
Pavan
  • 1