imageButton_white1.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
// TODO Auto-generated method stub
if (arg1.getAction() == MotionEvent.ACTION_DOWN) {
play(R.raw.white1);
imageButton_white1.setImageResource(R.drawable.white_down);
}
if (arg1.getAction() == MotionEvent.ACTION_UP) {
imageButton_white1.setImageResource(R.drawable.white_up);
}
return false;
}
});
imageButton_white2.setOnTouchListener(new View.OnTouchListener() {
imageButton_white3.setOnTouchListener(new View.OnTouchListener() {
...............我用这个方法只能按下一个键,滑动的时候这个键不会抬起,别的键也没有反应请问有什么办法能够实现滑键效果?
@Override
public boolean onTouch(View arg0, MotionEvent arg1) {
// TODO Auto-generated method stub
if (arg1.getAction() == MotionEvent.ACTION_DOWN) {
play(R.raw.white1);
imageButton_white1.setImageResource(R.drawable.white_down);
}
if (arg1.getAction() == MotionEvent.ACTION_UP) {
imageButton_white1.setImageResource(R.drawable.white_up);
}
return false;
}
});
imageButton_white2.setOnTouchListener(new View.OnTouchListener() {
imageButton_white3.setOnTouchListener(new View.OnTouchListener() {
...............我用这个方法只能按下一个键,滑动的时候这个键不会抬起,别的键也没有反应请问有什么办法能够实现滑键效果?
解决方案 »
- GPS 在真机上定不到位
- android自动退出
- 【贴图】退出时清除帐号密码问题!
- 求教贴图
- ContentProvider使用update时的错误,忘各位大侠指点,小弟新手~~~~~
- ★★★ android、linux、wince超多技术资源0分共享
- 如何制作rom
- xml布局里面的requestFocus 有什么用
- Android中Activity的启动流程是怎样的呢
- android客户端从服务器端下载文件
- 这种情况下service是何时启动的?
- 菜鸟求救……NoClassDefFoundError 与 Conversion to Dalvik format failed with error 1
只有你的手离开屏幕的时候才有Action_Up ,
这个可能就需要你去判断MotionEvent的点(可能有很多个点)是否在ImageButton 的区域内。需要自己把所有的ImageButton遍历一遍,相当于游戏的碰撞。
可能需要做的是去实现Activity的onTouchEvent,而不是给ImageButton一个OnTouchListener(个人想法)
借用你的方法我实现这个功能了,但是有个问题就是在ImageButton上滑动时不是很灵敏,在空白地方滑动非常顺畅,这是为什么呢?