aQ1711
aQ1711

Reputation: 27

How to permanently disable toggle button?

First I want to change the state of toggle button from false to true, then if its true I want to disable toggle button so no one can change it again.Please help me as I am new to android.

Upvotes: 1

Views: 3098

Answers (1)

Rachit Mishra
Rachit Mishra

Reputation: 6112

You may do like this,

    //get the button as
    ToggleButton tb =  (ToggleButton) findViewById(R.id.togglebutton1);
    // check it is enabled
    if(tb.isChecked()){
        //do something on enabling it
        tb.setEnabled(false);  // disable it
    }

Upvotes: 2

Related Questions