在 Holo 主题中,当您单击一个按钮时,它会变为蓝色并闪烁片刻。现在我希望按钮保持这种外观,并在下次单击时恢复正常外观。怎么做?
更新:我的代码:
public class HomeActivity extends SherlockActivity {
org.holoeverywhere.widget.Button bt;
boolean isPressed = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.home_layout);
bt = (org.holoeverywhere.widget.Button) findViewById(android.R.id.button1);
bt.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
if (!isPressed) {
isPressed = true;
} else {
isPressed = false;
}
bt.setPressed(isPressed);
}
return true;
}
});
}
}