Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Long click on list activity item
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Thao  
View profile  
 More options Dec 1 2008, 7:12 am
From: Thao <thao.uye...@gmail.com>
Date: Mon, 1 Dec 2008 04:12:03 -0800 (PST)
Local: Mon, Dec 1 2008 7:12 am
Subject: Long click on list activity item
Hi all,

I have an Activity that implements a ListActivty. In there, I have a
list of item that is wrapped by a custom adapter.

I would like to enable long click on each item in my list, but I can't
figure out how to do this...Could someone give an example please ?

Thank.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
tranbinh.bino@gmail.com  
View profile  
 More options Jan 2 2009, 4:04 am
From: "tranbinh.b...@gmail.com" <tranbinh.b...@gmail.com>
Date: Fri, 2 Jan 2009 01:04:20 -0800 (PST)
Local: Fri, Jan 2 2009 4:04 am
Subject: Re: Long click on list activity item
Hi,

Maybe this can help:

    @Override
    public void onCreateContextMenu(ContextMenu menu, View view,
ContextMenuInfo menuInfo) {
        AdapterView.AdapterContextMenuInfo info;
        try {
             info = (AdapterView.AdapterContextMenuInfo) menuInfo;
        } catch (ClassCastException e) {
            Log.e(TAG, "bad menuInfo", e);
            return;
        }

        long l = getListAdapter().getItemId(info.position);
    }

On Dec 1 2008, 7:12 pm, Thao <thao.uye...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
an...@akapost.com  
View profile  
 More options Feb 22 2009, 2:53 pm
From: an...@akapost.com
Date: Sun, 22 Feb 2009 11:53:24 -0800 (PST)
Local: Sun, Feb 22 2009 2:53 pm
Subject: Re: Long click on list activity item
Try looking at:

AdapterView.onItemLongClick()

ListView implements AdapterView, so you'll have access to that juicy
method, which will pass the id of the item clicked as well as the
item's view the same as with onListItemClick().

{begin code}

// ListActivity has a ListView, which you can get with:
ListView lv = getListView();

// Then you can create a listener like so:
lv.setOnItemLongClickListener( new AdapterView.OnItemLongClickListener
(){
                @Override
                public boolean onItemLongClick(AdapterView<?> av, View v, int
pos, long id) {
                        onLongListItemClick(v,pos,id);
                        return false;
        }

});

// You then create your handler method:
protected void onLongListItemClick(v,pos,id) {
      Log.i( TAG, "onLongListItemClick id=" + id );

}

{end code}

The standard onListItemClick() will still fire as well; my best guess
there is to keep a suppression boolean around, which isn't pretty.
Any other thoughts on this?

Phrases I searched for before finally stumbling across the proper
docs:
listactivity hold
listactivity longclick
android list long click
listactivity long click
listactivity long touch
android listview onLongClickListener

On Jan 2, 4:04 am, "tranbinh.b...@gmail.com" <tranbinh.b...@gmail.com>
wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
matthias  
View profile  
 More options Mar 31 2009, 8:39 am
From: matthias <m.kaepp...@googlemail.com>
Date: Tue, 31 Mar 2009 05:39:09 -0700 (PDT)
Local: Tues, Mar 31 2009 8:39 am
Subject: Re: Long click on list activity item
Hi,

On Feb 22, 9:53 pm, an...@akapost.com wrote:

> ...
> The standard onListItemClick() will still fire as well; my best guess
> there is to keep a suppression boolean around, which isn't pretty.
> Any other thoughts on this?

just return true from onItemLongClick(); this means you have consumed
the event, so it won't propagate up to the normal click handler.

Cheers,
Matthias


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Kaptkaos  
View profile   Translate to Translated (View Original)
 More options May 18, 7:12 pm
From: Kaptkaos <kaptkao...@gmail.com>
Date: Fri, 18 May 2012 16:12:24 -0700 (PDT)
Local: Fri, May 18 2012 7:12 pm
Subject: Re: Long click on list activity item

Ah, this was exactly what I needed. Thanks for the tip!


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »