开发者

On pressed button block the other buttons

开发者 https://www.devze.com 2023-04-07 23:20 出处:网络
How could I make my button to do the on click action even if the button is pressed and the finger is still on the screen (the b开发者_运维知识库utton is not released). Or I would accept the solution t

How could I make my button to do the on click action even if the button is pressed and the finger is still on the screen (the b开发者_运维知识库utton is not released). Or I would accept the solution that when a button is pressed and is not release, the other buttons on the layout to not be blocked.


Instead of using an OnClickListener consider using an OnTouchListener. You can then detect when the user's finger touches:ACTION_DOWN and releases ACTION_UP the button.

A method like this would probably work fine:

public boolean onTouch(View v, MotionEvent event)
    {

        switch(event.getAction()){

        case MotionEvent.ACTION_DOWN:
            //DISABLE THE OTHER BUTTONS
            break;

        case MotionEvent.ACTION_UP:
            // RE-ENABLE THE OTHER BUTTONS
            break;
        }
        return true;
    }


One option would be to use the onmousedown event rather than the onclick event in your javascript:

myButton.onmousedown = myOnClickFunction;
0

精彩评论

暂无评论...
验证码 换一张
取 消