onLongClickListener never get trigered
Asked Answered
T

2

7

I have a custom listView defined like this

public class DDListView extends ListView implements OnScrollChangedListener {

than I make an instance of it with name mExampleList I set onLongClickListener but it never get called, where is my problem ?

mExampleList.setOnLongClickListener(new OnLongClickListener() {

        public boolean onLongClick(View v) {
            // TODO Auto-generated method stub
            Log.v("vvv", "sdfsdf");
            return false;
        }
    });
Toddtoddie answered 30/9, 2011 at 14:43 Comment(0)
N
10

I think you want to be using OnItemLongClickListener instead of OnClickListener.

Nature answered 30/9, 2011 at 14:56 Comment(7)
It's the same OnLongItemClickListenerAvelar
there is no OnLongItemClickListenerPaine
@Paine developer.android.com/reference/android/widget/…Nature
1. List view has only ListView.setOnLongClickListener(View.OnLongClickListener l)! 2. ListView dont have method called setOnLongItemClickListener 3. Simplest way/hack to add LongItemCLick is registerForContextMenu ! EDIT: in your link you point to AdapterView.OnItemLongClickListener ... question: does ListView implements it ?Paine
@Paine Yes, it really does. Look at the documentation. I have an app that uses OnItemLongClickListener. Twice. And, I think the easiest way to use an OnItemClickListener is to use an OnItemClickListener.Nature
@AedonEtLIRA damn ... you're right ... i was thinking that setOnItemLongClickListener is hidden coz "intellisense" from Eclipse didn't show this method for mePaine
Upvoted. :) The answer is really useful - it solved a problem for me when using Gallery in connection with a custom (compound) widget.Indican
A
0

Mmmmm , are you trying to make all ListView longclckeable?

Some tips:

-Try first to see if normal OnClick gets fired;

-Try to see if you have setClickeable(true); on it;

-Try to see if you are really trying to do that and not an usual onItemClick() of the items in the list (to do this @override the function :
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {}

Avelar answered 30/9, 2011 at 14:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.