开发者

Android disabling a button

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

btn开发者_如何学编程SaturdayStartTime = (Button)findViewById(R.id.btnSaturdayStartTime);
btnSaturdayStartTime.setEnabled(false);     

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


Try using btnSaturdayStartTime.setClickable(false).

See setClickable from the docs.


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


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?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜