I am newbie to the programming world and my knowledge is limited. Please excuse me if i ask any blunder. My question is that.
I am creating an Activity which has START & STOP button. when user clicks on START button a service must start; and on STOP service must stop.
Now I want to disable my START button when i Click start button(service starts on click START button) and when clicks STOP button i want to see the START button as normal clickable button.
I have used .setEnabled(false) by creating the button object. i need help...Thanks in advance
1.1 To disable a submit button, you just need to add a disabled attribute to the submit button. $("#btnSubmit"). attr("disabled", true); 1.2 To enable a disabled button, set the disabled attribute to false, or remove the disabled attribute.
function clickFunc() { count += 1; //lets say id of button is btn if(count>3){ $('#btn'). prop('disabled', true); } } });
int count = 0;
if (count == 0) {
stop.setEnabled(false);
PlayButton.setEnabled(true);
}
@Override
public void onClick(View v) {
switch(v.getId()) {
case R.id.play:
count++;
play.setEnabled(false);
Toast.makeText(this, "Button Disabled", Toast.LENGTH_LONG).show();
Stopbutton.setEnabled(true);
break;
case R.id.stop:
Toast.makeText(this, "Button Disabled", Toast.LENGTH_LONG).show();
count--;
PlayButton.setEnabled(true);
stop.setEnabled(false);
break;
}
}
& check this link How to disable an Android button?
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