问题描述:

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!

网友答案:

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

网友答案:

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);
        }
    }
}
网友答案:

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.

相关阅读:
Top