Closed KaushikNathMIT closed 8 years ago
Which pages do you want to restrict access to?
The pages should be available. The user should not be able to swipe away a particular page to access the next page. Changing of pages is done programmatically.
Ok, so if changing of pages is done only programmatically, then the only thing you need to do is to disable touch in the FlippableStackView
(hint: it's just a ViewPager
). You can do that for example by extending FlippableStackView
and applying the mechanisms from here.
I have tried to use the setOnTouchListener()
flippableStackView.initStack(4, StackPageTransformer.Orientation.HORIZONTAL);
myadapter = new CustomAdapter(questionArray, posPointArray, negPointArray, getSupportFragmentManager(), viewPagerFragments);
flippableStackView.setAdapter(myadapter);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
flippableStackView.setCurrentItem(0);
}
flippableStackView.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
return true;
}
});`
But it doesnot seem to work. I can still swap from one page to another.
Use the one approach I sent you in the link (you will have to extend the FlippableStackView
).
I fixed it by using this line before returning true from the onTouch() function flippableStackView.setCurrentItem(flippableStackView.getCurrentItem());
That's interesting that you used the least reliable of the approaches from the StackOverflow thread (look at the first comment under the answer), and you used a random "solution" to make it barely work, instead of just going with a simple, elegant and solid solution (the one I pointed you to). Out of curiosity: why didn't you try the other approach?
I couldn't use the better solution, because I can't extend the FlippableStackView class. I am already extending the AppCompatActivity class. I actually have no idea how can I implement the way as u have mentioned.
On Fri 23 Sep, 2016, 7:29 PM Bartek Lipinski, notifications@github.com wrote:
That's interesting that you used the least reliable of the approaches from the StackOverflow thread (look at the first comment under the answer http://stackoverflow.com/a/13392198/1993204), and you used a random "solution" to make it barely work, instead of just going with a simple, elegant and solid solution (the one I pointed you to). Out of curiosity: why didn't you try the other approach?
— You are receiving this because you modified the open/close state.
Reply to this email directly, view it on GitHub https://github.com/blipinsk/FlippableStackView/issues/24#issuecomment-249200695, or mute the thread https://github.com/notifications/unsubscribe-auth/AO7EUe8g2Z9_XCel_hWlp5QlCFcZCfshks5qs9s7gaJpZM4KEyHF .
You should've just said that you're not sure how to extend a FlippableStackView
class, I'd be happy to help you with that. Just create another class
in your package, name it e.g. DisableableFlippableStackView
and use the following code as it's contents:
public class DisableableFlippableStackView extends FlippableStackView {
private boolean pagingEnabled;
public DisableableFlippableStackView(Context context) {
super(context);
setupView();
}
public DisableableFlippableStackView(Context context, AttributeSet attrs) {
super(context, attrs);
setupView();
}
private void setupView() {
this.pagingEnabled = true;
}
@Override
public boolean onTouchEvent(MotionEvent event) {
if (this.pagingEnabled) {
return super.onTouchEvent(event);
}
return false;
}
@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
if (this.pagingEnabled) {
return super.onInterceptTouchEvent(event);
}
return false;
}
public void setPagingEnabled(boolean enabled) {
this.pagingEnabled = enabled;
}
}
And use DisableableFlippableStackView
instead of FlippableStackView
in your layout xml.
Thank you so much It worked!!!!
👍
👍
I need your help,How to dynamically set the page only up or down?Thank you
Is there a way I can restrict the scrolling between the pages. I only want to scroll when some condition is fullfilled.