Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How keep a button pressed until the method end

Tags:

java

android

I need to keep a button pressed until the method end, because the user not can press again while the button stays pressed.

I tryed this:

on create:

Button btnSend= (Button) findViewById(R.id.btnSend);
btnSend.setOnClickListener(onClickbtnSend);

Method:

Button.OnClickListener onClickbtnSend= new Button.OnClickListener() {
   @Override
   public void onClick(View v){
     try{
         v.setPressed(true);

         //do something ......     

     } catch(Exception e){
       e.printStackTrace();
     }
   v.setPressed(false);
}

Somebody have idea? Thanks

like image 837
lfrancatto Avatar asked May 06 '26 08:05

lfrancatto


1 Answers

You may want to use a ToggleButton instead since your button seems to have two states (busy or not).

like image 147
Frank Avatar answered May 07 '26 22:05

Frank



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!