我如何禁用多点触控,并从我的活动拉 [英] How can I disable the multi-touch and the pulling from my activity

查看:114
本文介绍了我如何禁用多点触控,并从我的活动拉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

欲禁用多触摸动作,并从我的屏幕和从我的活动的拉动动作。我只想用行动影响了我的活动。我该怎么办呢?

I want disable the multi-touch action and the pulling action from my screen and from my activity. I want only use the impact action for my activity. How can I do it?

我要禁用多点触控,并从 A 视图中的拉动作用。

I want disable the multi-touch and the pulling action from the a view.

a.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                if (event.getX(0)>=20 && event.getY(0)>=60 && event.getX(0)<=160 && event.getY(0)<=150) {
                    B b = new B(getApplicationContext());
                    relativeLayout.addView(b);
                }
                return true;
            }
        })

推荐答案

如果我正确地理解你的问题,我想你想使用 OnClickListener ,而不是一个一个 OnTouchListener

If I'm to understand your question correctly, I think you want to use an OnClickListener instead of an OnTouchListener.

试试这个:

a.setOnClickListener(new OnClickListener()
{
    @Override
    public void onClick(View arg0)
    {
        B b = new B(getApplicationContext());
        relativeLayout.addView(b);
    }
});

这是假设你想要的任何地方挖掘在 A 添加 B RelativeLayout的。如果你想挖掘在 A 的特定区域,你应该添加一个新的观点来 A 覆盖的区域,然后点击监听器添加到新的观点。

This is assuming you want to tap anywhere within a to add b to your relativeLayout. If you want to tap a specific area within a you should add a new view to a that covers that area and then add the click listener to that new view.

这篇关于我如何禁用多点触控,并从我的活动拉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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