Example on ToggleButton

后端 未结 7 1296
悲哀的现实
悲哀的现实 2021-01-12 07:08

I am developing an application using a toggle button, I entered 1 or 0 in EditText. When button is clicked, the toggle button has to change if I enter 1 the tog

7条回答
  •  别那么骄傲
    2021-01-12 07:31

    
    

    Within the Activity that hosts this layout, the following method handles the click event:

    public void onToggleClicked(View view) {
        // Is the toggle on?
        boolean on = ((ToggleButton) view).isChecked();
    
        if (on) {
            // Enable vibrate
        } else {
            // Disable vibrate
        }
    }
    

提交回复
热议问题