ListView, mark the position where the user touches

后端 未结 3 1131
谎友^
谎友^ 2021-01-17 00:53

I have a custom listview with a setOnTouchListener

view.setOnTouchListener(new OnTouchListener() {

        @Override
        publi         


        
3条回答
  •  鱼传尺愫
    2021-01-17 01:44

    In your case you need either ACTION_UP or ACTION_DOWN event not ACTION_MOVE so to avoid ACTION_MOVE you can do something like this:

    if(event.getAction() == MotionEvent.ACTION_DOWN)
        {
             isDown = false;            
        }
        if(event.getAction() == MotionEvent.ACTION_UP && !isDown)
        {
            // action you want to perform
        }
        if(event.getAction() == MotionEvent.ACTION_MOVE)
        {
            isDown = true;
        }
    

    as far as changing color is concerned, you can store previous view in a global variable and while going for next touch, you can change that global view color to normal.

提交回复
热议问题