3

I can't figure out why this wouldn't set a button to be disabled?

btnSaturdayStartTime = (Button)findViewById(R.id.btnSaturdayStartTime);
btnSaturdayStartTime.setEnabled(false);     

When I click on the button it still fires the listener.

1
  • Are you sure you got the right id for your button? That should work in reality. Commented May 25, 2011 at 20:23

3 Answers 3

3

Try using btnSaturdayStartTime.setClickable(false).

See setClickable from the docs.

Sign up to request clarification or add additional context in comments.

Comments

2

try the method : Button.setClickable(false) ; or delete the listener on your button like this : button.setOnClickListener(null);

Comments

0

Maybe the button is recreated or re-enabled between you disabling it an the user click interaction. Are you sure you are disabling the right button? What version of Android are you targeting?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.