attach onClickListener to ToggleButton
问题 I have a ToggleButton and I need to set up simple click actions. How do I implement a simple click listener for a ToggleButton? If you need details please ask. 回答1: ToggleButton extends View, so you can simply use View.setOnClickListener(), like this: // get your ToggleButton ToggleButton b = (ToggleButton) findViewById(R.id.myButton); // attach an OnClickListener b.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // your click actions go here } }); 回答2: this