onInterceptTouchEvent禁用ACTION_DOWN /移动/ UP [英] onInterceptTouchEvent to disable ACTION_DOWN/ MOVE/UP

查看:206
本文介绍了onInterceptTouchEvent禁用ACTION_DOWN /移动/ UP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有codeD哪家做这样的工作程序

i have coded a program which which does a task like this

0 1 2 3 4

0 1 2 3 4

5 6 7 8 9

5 6 7 8 9

料想这些都是我设计的意见。现在假设用户已经触摸(按下事件)1,一些字符串被设定为1下。但是当用户滑动到2不会释放他的手指在键1,那么就应该设置字符串为2降,但该字符串仍是1降..我没有得到如何使这一切成为可能。它可能已经被在1 ACTION_MOVE事件中完成。但我没有得到什么做的,禁止其进一步的事件(Up事件)。后的整个滑动时,我释放字符串被设定为1向上键。所以它是不承认的议案下来2 3 4等事件,它停留在掉电模式。我认为这可能与完成 onInterceptTouchEvent,但我没有得到它正确。下面是我的源$ C ​​$ C。分享它。如果可能的乌拉圭回合的意见给我如何将其纳入我的code一些示例code

suppose these are the views in my layout. Now suppose user has touched (down event) on 1,some string is set to "1 down". but when the user slides to 2 without releasing his finger on key 1 , then it should set the string to "2 down", but the string is still "1 down".. i am not getting how to make this possible .it may have to be done on ACTION_MOVE event of 1 . but i am not getting what to do ,to disable its further events (Up event). after the entire sliding when i release the key the string is set to "1 up". so it is not recognizing the motion down events of 2 3 4 etc. it is staying in down mode. i think it could be done with onInterceptTouchEvent, but i did not get it correctly .below is my source code. share ur views on it.if possible give me some sample code on how to incorporate it into my code

@覆盖 公共无效的onCreate(包savedInstanceState)  {

@Override public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);


// select_btn = (Button) findViewById(R.id.ok);
// home_btn = (Button) findViewById(R.id.home);
et = (EditText) findViewById(R.id.entry);
et.setText("", TextView.BufferType.EDITABLE);
b = new Bundle();


try {
    Thread.sleep(2000);
} catch (InterruptedException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
}

for (int i = 0; i < mybtn.length; i++) {
    String btnid = "btn" + i;
    int resid = getResources().getIdentifier(btnid, "id",
            getPackageName());
    mybtn[i] = (Button) findViewById(resid);
    mybtn[i].setOnTouchListener(this);

}

}

推荐答案

移动INT电流= 0;出onTouch方法。 它被称为任何时间有在屏幕上的运动,并把0在当前的

Move "int current = 0;" out of onTouch method. It is being called any time there's a movement on the screen and put 0 in current.

顺便说一句,我看你用我的code(的一部分): <一href="http://stackoverflow.com/questions/9329595/motion-event-capturing-in-android#comment11777807_9329595">Motion在Android的事件捕获

by the way, I see you used my code (part of it): Motion Event Capturing in android

你至少可以做的是接受的答案,或将其标记为有用

the least you can do is to accept the answer or mark it as useful

这篇关于onInterceptTouchEvent禁用ACTION_DOWN /移动/ UP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆