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 button 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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top