Search code examples
androidbuttonslide

Sliding over buttons


I want to be able to 'slide' over my buttons and perform like they were each clicked when touched. (Act on 0, not on 1). How can I accomplish this?


Solution

  • button.setOnTouchListener would do the trick

    button.setOnTouchListener(new OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getAction() == MotionEvent.ACTION_DOWN ) {
                    //Insert desired code here
                    return true;
                }
                return false;
            }
        });
    

    Could you explain what you mean by "slide over these buttons and make them react in a row"?