单击按钮后如何保持按下按钮? [英] How can I keep a button as pressed after clicking on it?
本文介绍了单击按钮后如何保持按下按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能的重复:
安卓.如何在按钮创建的操作完成之前保持按钮显示为 PRESSED?
我有一个按钮,我希望当我按下它时,它保持按下状态(在 Froyo 上显示绿色).
I have a button, and I want that when I press it, it stays as pressed (with the green color on Froyo).
有什么帮助吗?
mycodes_Button = (Button) findViewById(R.id.mycodes);
...
if (saved_Button.isPressed())
{
saved_Button.setFocusable(true);
}
类似的东西?
推荐答案
使用以下代码.很有用.
Use the following code. It's useful.
mycodes_Button.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
mycodes_Button.setPressed(true);
return true;
}
});
这篇关于单击按钮后如何保持按下按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文