开发者

How do you check whether a button is enabled or not in Android?

开发者 https://www.devze.com 2023-03-09 03:28 出处:网络
In Android I can set a button to be enabled or disabled by doing the following: button.setEnabled(true); or button.setEnabled(false);

In Android I can set a button to be enabled or disabled by doing the following:

button.setEnabled(true); or button.setEnabled(false);

How do I check whether the butto开发者_StackOverflow社区n enabled state is true or false?


Reading the manual every now and then doesn't hurt:

http://developer.android.com/reference/android/view/View.html#isEnabled%28%29

Example:

ImageButton myButton = (ImageButton) findViewById(R.id.epic_button);

if (myButton.isEnabled()){
    //then the button is enabled.
}


button.isEnabled() 

returns true if enabled

0

精彩评论

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