Android: Slidingdrawer.lock() blocking touch input for the rest of the layout

1.6k views Asked by At

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!

3

There are 3 answers

0
Ste On

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.

1
SimooDroid On

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

0
yochi376 On

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);
        }
    }
}