alex mike alex mike - 5 months ago 155
Android Question

disable swipe in SlidingUpPanelLayout

this is my SlidingPanelLayout

mLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);

mLayout.addPanelSlideListener(new SlidingUpPanelLayout.PanelSlideListener() {


@Override
public void onPanelSlide(View panel,final float slideOffset) {
Log.d(TAG, "onPanelSlide, offset " + slideOffset);






}

@Override
public void onPanelStateChanged(View panel, SlidingUpPanelLayout.PanelState previousState, SlidingUpPanelLayout.PanelState newState) {
Log.i(TAG, "onPanelStateChanged " + newState);
}
});


how can i disable swipe on it i found solution say use this

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return false;
}

@Override
public boolean onTouchEvent(MotionEvent ev) {
return false;
}


but i dosent extend SlidingPaneLayout please don't make this question as duplicate it's different how can i disable swipe with this my code dont tell me extend it i want to work like this any idea ot and when i dosent extend SlidingPaneLayout this code

@Override
public boolean onInterceptTouchEvent(MotionEvent ev) {
return false;
}

@Override
public boolean onTouchEvent(MotionEvent ev) {
return false;
}


not work its show error so how can i disable swipe without extend

Answer

according to SlidingUpPanelLayout

just use

mLayout.setEnabled(false);

thats all :)