android setOnLongClickListner不适用于onTouch事件 [英] android setOnLongClickListner does not work with onTouch event

查看:181
本文介绍了android setOnLongClickListner不适用于onTouch事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个可拖动和缩放的图像视图但现在我还需要在我的图像视图上放置setOnLongClickListner。我已经做到了,但它不起作用。但当我禁用ontouch事件时,它开始工作。请有人告诉我如何解决这个问题。
这里是我的代码

i have a image view which is drag able and zoom able but now i also need to put setOnLongClickListner on my image view. i have done that but it is not working. but when i disabled the ontouch event it started working. can anybody tell me please how to fix that. here is my code

    image.layout(0, 30, screenWidth, screenHeight - 30);
    image.setScaleType(ImageView.ScaleType.FIT_XY);


    params = new RelativeLayout.LayoutParams(screenWidth, screenHeight - 30);
    params.leftMargin = 0;
    params.topMargin = 30;


    layout.addView(image, params);

    image.setOnLongClickListener(new View.OnLongClickListener() {
        public boolean onLongClick(View v) {


            Log.i("its working", "its working");

            return true;
                    }
    });

    image.setOnTouchListener(this);

i,非常感谢。

非常感谢。

推荐答案

我认为Object可以有onClick或onTouch,它会使用任何最后一个定义是。我最近在一些应用程序中也注意到了这一点。

I think that the Object can have either an onClick or an onTouch, and it will use whatever the last one defined is. I have noticed this recently in some of my apps too.

这篇关于android setOnLongClickListner不适用于onTouch事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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