其使用OnClickListener方法也能用的
toggleButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ToggleButton tb = (ToggleButton)v;
if( tb.isChecked())
image.setImageResource(R.drawable.sad);
else
image.setImageResource(R.drawable.sleep);
}
});
toggleButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
ToggleButton tb = (ToggleButton)v;
if( tb.isChecked())
image.setImageResource(R.drawable.sad);
else
image.setImageResource(R.drawable.sleep);
}
});
2015-07-27