I have a "start" button on my content view, i want to replace it with a "stop" button when clicking on it.
i have already defined a "start" and a "stop" button in xml , what should i do next? thanks a lot!
You need a reference to your button in the code:
Button stop = (Button) findViewById( R.id.stopButton );
Button start = (Button) findViewById( R.id.startButton );
Add onClickListeners for both and when start is clicked you add these lines:
start.setVisibility( View.GONE );
stop.setVisibility( View.VISIBLE );
In stops onClickListener you do the opposite:
start.setVisibility( View.VISIBLE );
stop.setVisibility( View.GONE );
Or you could just let one Button handle both start and stop and just change the text of it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With