Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 789
atbebtg Avatar asked May 27 '11 04:05

atbebtg


1 Answers

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.
}
like image 79
DallaRosa Avatar answered Oct 02 '22 08:10

DallaRosa