keep android button selected state

前端 未结 5 787
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-17 18:03

I know this is a question that has been asked many times before, but I can\'t seem to solve it in my code. I have two buttons, and when one is pressed, I would like to keep

5条回答
  •  萌比男神i
    2020-12-17 18:39

    I searched on Google and found this Stack Overflow post:
    How can i keep one button as pressed after click on it?

    mycodes_Button.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            mycodes_Button.setPressed(true);
            return true;
        }
    });
    

    But read the comment, it's pretty interesting!

提交回复
热议问题