Android:Slidingdrawer.lock() 阻止布局其余部分的触摸输入

发布于 2024-10-16 09:21:12 字数 351 浏览 1 评论 0原文

我有一个带有viewFlipper 和slidingDrawer 的活动。 SlidingDrawer 的处理程序包含一个额外的可单击按钮。

问题是,处理程序上的额外按钮仅在 sliderDrawer 锁定时注册 onClick,而当 sliderDrawer 锁定时,viewFlipper(布局的其余部分)不再响应gestureListener,因此我无法在视图之间翻转。

有没有人对如何在 sliderDrawer 的处理程序上制作一个可点击的额外按钮,同时在 viewFlipper 上有一个可用的手势侦听器有任何建议?

也许有人知道为什么 slipDrawer.lock() 会阻止布局其余部分的触摸输入?

谢谢!

I have an Activity with a viewFlipper and a slidingDrawer.
The SlidingDrawer's Handler contains an extra button wich is clickable.

The problem is, the extra button on the handler only registers onClick when the slidingDrawer is locked, and when the slidingDrawer is locked, the viewFlipper (the rest of the layout) does not respond to the gestureListener anymore and therefore I cannot flip between views.

Does anyone have any suggestions on how to make an extra button on a slidingDrawer's handler clickable and at the same time have a working gesturelistener on the viewFlipper?

Maybe someone knows why slidingDrawer.lock() would block the touch input for the rest of the layout?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

一百个冬季 2024-10-23 09:21:12

这是一个已知问题
请参阅此解决方案
http://code.google.com/p/android/issues/detail ?id=17844

This is a known issue
See this solution
http://code.google.com/p/android/issues/detail?id=17844

叫思念不要吵 2024-10-23 09:21:12

这个解决方案对我有用:扩展SlidingDrawer并重写onTouchEvent方法(如果slidingdrawer被锁定,应该返回false而不是true):

package xxx.slidingdrawer;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

@SuppressWarnings("deprecation")
public class SlidingDrawer extends android.widget.SlidingDrawer {

    private boolean mLocked;

    public SlidingDrawer(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public void lock() {
        super.lock();
        mLocked = true;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (mLocked) {
            return false;
        } else {
            return super.onTouchEvent(event);
        }
    }
}

this solution works for me : extend SlidingDrawer and override onTouchEvent method (should return false and not true if slidingdrawer is locked) :

package xxx.slidingdrawer;

import android.content.Context;
import android.util.AttributeSet;
import android.view.MotionEvent;

@SuppressWarnings("deprecation")
public class SlidingDrawer extends android.widget.SlidingDrawer {

    private boolean mLocked;

    public SlidingDrawer(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public void lock() {
        super.lock();
        mLocked = true;
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        if (mLocked) {
            return false;
        } else {
            return super.onTouchEvent(event);
        }
    }
}
歌枕肩 2024-10-23 09:21:12

我找到了导致此问题的滑动抽屉的哪个部分。如果slidingDrawer被锁定,onInterceptTouchEvent()方法返回false。

不管怎样,我通过创建一个新的 Activity 来伪造一个 sliderDrawer 来“解决”这个问题,该 Activity 可以使用以下方法上下滑动:

startActivity(yourIntent);
    overridePendingTransition(R.anim.yourNextActivity_InAnimation, R.anim.yourCurrentActivity_OutAnimation);

缺点当然是不再可以用手指拖动抽屉。

I found what part of the slidingDrawer that was causing this. The onInterceptTouchEvent() method returns false if the slidingDrawer is locked.

Anyway, I "solved" this problem by fakeing a slidingDrawer by creating a new Activity wich slides up and down using:

startActivity(yourIntent);
    overridePendingTransition(R.anim.yourNextActivity_InAnimation, R.anim.yourCurrentActivity_OutAnimation);

The downside is ofcourse that it is no longer possible to drag the drawer with your finger.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文