user690936
user690936

Reputation: 1035

Android - starting an action on press and stoping on release

I have a List of items, and i want when the user presses down on one of the items a popup window will open up, and when he lets go, it will close.

i know how to make a popup open when you press the key (endless examples over the internet) by using setOnItemClickListener.. how do i make it stop when i realase the item?

thank you.

Matt

Upvotes: 0

Views: 754

Answers (1)

Sam
Sam

Reputation: 86948

Consider using the OnTouchListener() instead, it captures separate events for down, up, move, etc:

view.setOnTouchListener(new OnTouchListener() {
    public boolean onTouch(View v, MotionEvent event) {
        switch(event.getAction()) {
        case MotionEvent.ACTION_DOWN:
            // Open popup
            break;
        case MotionEvent.ACTION_UP:
            // Close popup
        }
        return true;
    }
});

Upvotes: 2

Related Questions