单击按钮后如何保持按下状态? [英] How can I keep a button as pressed after clicking on it?
本文介绍了单击按钮后如何保持按下状态?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Possible Duplicate:
Android. How do I keep a button displayed as PRESSED until the action created by that button is finished?
我有一个按钮,当我按下按钮时希望它保持按下状态(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屋!
查看全文