Reputation: 4968
in my app i have three buttons namely A,B and C. I want the buttons B and C to be disabled until button A is clicked. they should be ready to perform this function until button A is clicked how to do this.....
Upvotes: 1
Views: 2290
Reputation: 91
Disable the button
myButton.setEnabled(false);
Enable the button
myButton.setEnabled(true);
Upvotes: 0
Reputation: 236
// assuming valid references to buttons
buttonB.setEnabled(false);
buttonC.setEnabled(false);
buttonA.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
buttonB.setEnabled(true);
buttonC.setEnabled(true);
}
});
Upvotes: 1
Reputation: 11946
protected void onCreate(Bundle savedInstanceState)
{
buttonB.setEnabled(false);
buttonC.setEnabled(false);
}
public void onClick(View v)
{
if (v == buttonA)
{
buttonB.setEnabled(true);
buttonC.setEnabled(true);
}
}
Upvotes: 3
Reputation: 10011
you should write this will creating your app
myButton.setEnabled(false);
and in the button click function you should enable it by doing this.
myButton.setEnabled(true);
Upvotes: 3