Changing pagetitle in Android Viewpager - android

I have a ViewPager in which I am using the getPageTitle method to get the title of the current page.
Here is the Adapter code:
#Override
public Fragment getItem(int i) {
details = productData.get(i);
Fragment fragment = new ProductViewFragment();
Bundle args = new Bundle();
args.putInt(ProductViewFragment.ARG_SECTION_NUMBER, i + 1);
fragment.setArguments(args);
return fragment;
}
#Override
public int getCount() {
return productData.size();
}
public CharSequence getPageTitle(int position)
{
return (position+1)+" of "+myData.size();
}
Now I would like to update the page titles of the previous and next fragments. I want to name them as "previous" and "next". And it should be updated dynamically on subsequent pages also.
I am able to get the current page title number. For example, when I view the 5th fragment, the current fragment will show the title properly. And at both the corners of the ViewPager it shows the previous page title number on the left and next page title number on the right. Now, I want to have the page titles as "previous" on the left and "next" on the right, similar to the Gmail app and how it shows the mail count in the ViewPager.
The main thing I want to know is how can I access/modify the page title data of the next/previous fragments from the current fragment like they do in the Gmail app?

I based this on the samples that come with the ViewPagerIndicator.
You basically listen for when the page changes and tell the adapter to display a different page title depending on the current position.
If you have those samples working and you just replace those two files, then try the sample Titles->Default and it works fine for me...
Changed the code for TestFragmentAdapter like this:
package com.viewpagerindicator.sample;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import com.viewpagerindicator.IconPagerAdapter;
class TestFragmentAdapter extends FragmentPagerAdapter implements IconPagerAdapter {
protected static final String[] CONTENT = new String[] { "This", "Is", "A", "Test", };
protected static final int[] ICONS = new int[] {
R.drawable.perm_group_calendar,
R.drawable.perm_group_camera,
R.drawable.perm_group_device_alarms,
R.drawable.perm_group_location
};
private int mCount = CONTENT.length;
// CHANGE STARTS HERE
private int current_position=0;
public void set_current_position(int i) {
current_position = i;
}
// CHANGE ENDS HERE
public TestFragmentAdapter(FragmentManager fm) {
super(fm);
}
#Override
public Fragment getItem(int position) {
return TestFragment.newInstance(CONTENT[position % CONTENT.length]);
}
#Override
public int getCount() {
return mCount;
}
#Override
public CharSequence getPageTitle(int position) {
// CHANGE STARTS HERE
if (position == current_position-1) {
return "Previous";
} else if (position == current_position+1) {
return "Next";
}
// CHANGE ENDS HERE
return TestFragmentAdapter.CONTENT[position % CONTENT.length];
}
#Override
public int getIconResId(int index) {
return ICONS[index % ICONS.length];
}
public void setCount(int count) {
if (count > 0 && count <= 10) {
mCount = count;
notifyDataSetChanged();
}
}
}
the code for SampleTitlesDefault looks like this (added the OnPageChangeListener)
package com.viewpagerindicator.sample;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import com.viewpagerindicator.TitlePageIndicator;
// CHANGE ADDED implements.... HERE
public class SampleTitlesDefault extends BaseSampleActivity implements ViewPager.OnPageChangeListener {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.simple_titles);
mAdapter = new TestFragmentAdapter(getSupportFragmentManager());
mPager = (ViewPager)findViewById(R.id.pager);
mPager.setAdapter(mAdapter);
mIndicator = (TitlePageIndicator)findViewById(R.id.indicator);
mIndicator.setViewPager(mPager);
// CHANGE STARTS HERE
mIndicator.setOnPageChangeListener(this);
// CHANGE ENDS HERE
}
// CHANGE STARTS HERE
#Override
public void onPageScrolled(int i, float v, int i1) {
}
#Override
public void onPageSelected(int i) {
mPager = (ViewPager)findViewById(R.id.pager);
((TestFragmentAdapter)mPager.getAdapter()).set_current_position(i);
}
#Override
public void onPageScrollStateChanged(int i) {
}
// CHANGE ENDS HERE
}

Related

Custom Tab layout with ViewPager2

I am trying to use custom tabs for my ViewPager2 via the TabLayout.Tab.setCustomView method. But it doesn't work.
Here is a code snippet from my Activity for preparing the ViewPager2 with a TabLayout:
#Override
protected void onCreate(Bundle savedInstanceState)
{
...
mMyViewPager2 = findViewById(R.id.view_pager);
mMyViewPager2.setAdapter(new MyPagerAdapter(this));
mMyTabLayout = findViewById(R.id.media_tab);
new TabLayoutMediator(mMyTabLayout, mMyViewPager2, myTabHandler).attach();
}
private class MyPagerAdapter extends FragmentStateAdapter
{
...
}
And here is the code snippet for my TabLayoutMediator.TabConfigurationStrategy (also inside my Activity):
private TabLayoutMediator.TabConfigurationStrategy myTabHandler = new TabLayoutMediator.TabConfigurationStrategy()
{
private TextView tabTitle;
private TextView tabSubtitle;
#Override
public void onConfigureTab(#NonNull TabLayout.Tab tab, int position)
{
View tabView = LayoutInflater.from(MyActivity.this).inflate(R.layout.tab_layout, null, false);
tabTitle = tabView.findViewById(R.id.tab_title);
tabSubtitle = tabView.findViewById(R.id.tab_subtitle);
tabTitle.setText("Title" + (position + 1));
tabSubtitle.setText("Subtitle" + (position + 1));
tab.setCustomView(tabView);
}
}
But with the above setup, the tabs remain blank.
I've also tried the following approach in my TabConfigurationStrategy (from this post); but it doesn't work, either:
FrameLayout frameLayout = new FrameLayout(MyActivity.this);
frameLayout.addView(tabView);
I'd like to know what is wrong with my code, and how can I correct it to show custom tab layouts with ViewPager2.
From setCustomView() documentation:
If the provided view contains a TextView with an ID of text1 then that
will be updated with the value given to setText(CharSequence)
So try changing the tabTitle's Id to "#android:id/text1".
Now for the subtitle, I am not certain of this. Using"#android:id/text2" might be worth a try. Note: "#android:id/text2" exists.
Nevertheless, you can apply your own layout declaratively to the TabItems using android:layout="", thus negating the need for you to do it programmatically. There is an example of the declarative version in the TabLayout documentation. So I believe something like this would work:
<TabLayout
...>
<TabItem
....
android:layout="#layout/linearLayout_tabitem_1"/>
<TabItem
....
android:layout="#layout/linearLayout_tabitem_2"/>
</TabLayout>
You can define the the title of tabs in your pagerAdapter itself.
#Override
protected void onCreate(Bundle savedInstanceState)
{
...
MyPagerAdapter adapter = new MyPagerAdapter(this, getSupportFragmentManager() , 2);
mMyTabLayout = findViewById(R.id.media_tab);
mMyViewPager2 = findViewById(R.id.view_pager);
pager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(mMyTabLayout));
mMyViewPager2.setAdapter(adapter);
mMyTabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
#Override
public void onTabSelected(TabLayout.Tab tab) {
mMyViewPager2.setCurrentItem(tab.getPosition());
setTabView(tab.getPosition());
}
#Override
public void onTabUnselected(TabLayout.Tab tab) {
}
#Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
}
private void setTabView(int index) {
TabLayout.Tab tab = mMyTabLayout.getTabAt(index);
tab.setCustomView(R.layout.tab_layout);
((TextView) tab.getCustomView().findViewById(R.id.tabSubtitle)).setText("Subtitle" + (position + 1));
}
private class MyPagerAdapter extends FragmentStatePagerAdapter
{
private Context mContext;
private int mCount;
public MyPagerAdapter(Context context, FragmentManager fm , int count) {
super(fm);
mContext = context;
mCount = count;
notifyDataSetChanged();
#Override
public Fragment getItem(int position) {
if (position == 0)
return someFragment();
else if (position == 1)
return someOtherFragment();
}
#Override
public int getCount() {
return mCount;
}
#Override
public CharSequence getPageTitle(int position) {
// Generate title based on item position
switch (position) {
case 0:
return "Title" + position+1;
case 1:
return "Title" + position+1;
default:
return null;
}
}
}

How to save dynamically added pages in viewpager Android

With the help of Vivek Pratap Singh and astuetz codes from following questions(Remove Fragment Page from ViewPager in Android and Android saving dynamically added viewpager's fragment while coming back from another activity and reopening app),
In my previous question in stack overflow I used inbuild method onDestroy, as it looks like it will save all the dynamically added fragments in viewpager.
But it's not happening, I am able to see only one intial static page(i.e. fragment) when I restart my app or navigate to another activity and come back to my activity containing the viewpager with fragments.Could any one please help me on this question.
Here is my source code for your reference:
public class MainActivity extends FragmentActivity implements TextProvider {
private Button mAdd;
private Button mRemove;
private ViewPager mPager;
int position;
private MyPagerAdapter mAdapter;
private ArrayList<String> mEntries = new ArrayList<String>();
#Override
public void onSaveInstanceState(Bundle bundle) {
super.onSaveInstanceState(bundle);
bundle.putInt("currenItem", mPager.getCurrentItem());
}
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mPager = (ViewPager) findViewById(R.id.pager);
if (savedInstanceState != null) {
mPager.setCurrentItem(savedInstanceState.getInt("currentItem", 0));
}
mEntries.add("page 1");
mAdd = (Button) findViewById(R.id.add);
mRemove = (Button) findViewById(R.id.remove);
mAdd.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View view) {
addNewItem();
}
});
mRemove.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View view) {
removeCurrentItem();
}
});
mAdapter = new MyPagerAdapter(this.getSupportFragmentManager(), this);
mPager.setAdapter(mAdapter);
mPager.setOffscreenPageLimit(3);
}
private void addNewItem() {
// int position = mPager.getCurrentItem();
mEntries.add("page ");
mAdapter.notifyDataSetChanged();
}
private void removeCurrentItem() {
int position = mPager.getCurrentItem();
if(position != 0){
mEntries.remove(position);
}else{
Toast.makeText(getApplicationContext(), "Sorry", Toast.LENGTH_LONG).show();
}
mAdapter.notifyDataSetChanged();
}
#Override
public String getTextForPosition(int position) {
return mEntries.get(position);
}
#Override
public int getCount() {
return mEntries.size();
}
private class MyPagerAdapter extends FragmentPagerAdapter {
private TextProvider mProvider;
private long baseId = 0;
public MyPagerAdapter(FragmentManager fm, TextProvider provider) {
super(fm);
this.mProvider = provider;
}
#Override
public Fragment getItem(int position) {
switch(position) {
case 0:
return FragmentOne.newInstance(mProvider.getTextForPosition(position));
case 1:
return FragmentTwo.newInstance(mProvider.getTextForPosition(position));
case 2:
return FragmentThree.newInstance(mProvider.getTextForPosition(position));
default: return FragmentOne.newInstance(mProvider.getTextForPosition(position));
}
}
#Override
public int getCount() {
return mProvider.getCount();
}
//this is called when notifyDataSetChanged() is called
#Override
public int getItemPosition(Object object) {
// refresh all fragments when data set changed
return PagerAdapter.POSITION_NONE;
}
#Override
public long getItemId(int position) {
// give an ID different from position when position has been changed
return baseId + position;
}
#Override
public void destroyItem(ViewGroup container, int position, Object object) {
}
/**
* Notify that the position of a fragment has been changed.
* Create a new ID for each position to force recreation of the fragment
* #param n number of items which have been changed
*/
public void notifyChangeInPosition(int n) {
// shift the ID returned by getItemId outside the range of all previous fragments
baseId += getCount() + n;
}
}
}

PageViewer: How to get class of adjacent pages?

I use a PageViewer to scroll through two types of fragments.
One of them has an EditText the other multiple buttons.
Upon entering the EditText Fragment I automatically open the softkeyboard. Upon entering the Button Fragment i close it.
This works fine.
The problem is that I have multiple EditText Fragments as direct neighbours to each other.
-> I dont want the keyboard to be closed when transitioning from one EditText Fragment to the next.
For this I somehow need to predict the class to which I am transitioning next.
Is there a way to achieve this?
Note: I close the keyboard in the pageTransform method as soon as a swipe movement occurs.
EDIT
because of an request in the comments here my PagerAdapter:
public class ButtonCollectionPagerAdapter extends FragmentStatePagerAdapter {
public ButtonCollectionPagerAdapter(FragmentManager fm) {
super(fm);
}
private Fragment currentFragment;
#Override
public Fragment getItem(int i) {
Bundle args = new Bundle();
List<MultipleChoiceQuestion> multipleChoiceQuestions = QuestionTexts.getMCQuestionTexts();
List<String> questionTexts = QuestionTexts.getQuestionTexts();
if(i < multipleChoiceQuestions.size()){
String question = multipleChoiceQuestions.get(i).getText();
ArrayList<String> choices = (ArrayList<String>) multipleChoiceQuestions.get(i).getChoices();
currentFragment = ButtonFragment.newInstance(question, choices, i);
} else if(i < (multipleChoiceQuestions.size() + questionTexts.size())){
currentFragment = TextViewFragment.newInstance(questionTexts.get(i - multipleChoiceQuestions.size()), i);
} else {
currentFragment = SendFragment.newInstance(i);
}
return currentFragment;
}
#Override
public int getCount() {
return 23;
}
#Override
public CharSequence getPageTitle(int position) {
return "OBJECT " + (position + 1);
}
#Override
public void setPrimaryItem(ViewGroup container, int position, Object object){
super.setPrimaryItem(container, position, object);
currentFragment = (Fragment) object;
((PagerAdapterUpdateProgress) object).onGettingPrimary(position);
}
public Fragment getCurrentFragment() {
return currentFragment;
}
}
I think the more simple way to do that is to open/close keyboard directly from your fragments. You can determine when your fragment becomes visible by overriding setUserVisibleHint method of your fragment. The code in this method for your EditText Fragment should just show keyboard, and the code for other fragment should hide keyboard.
This is an interesting question.
I believe that you can achieve what you are doing by using ViewPager.OnPageChangeListener listener especially onPageSelected(int position) method in which we could get the position of the currently selected fragment after the swipe animation has finished.
mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
#Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
}
#Override
public void onPageSelected(int position) {
Log.d("ViewPager", "Page selected " + position);
onPageSelectedLogic(position);
}
#Override
public void onPageScrollStateChanged(int state) {
}
});
// This is because the first fragment doesn't fire the OnPageChangeListener.
onPageSelectedLogic(0);
an this is the implementation of onPageSelectedLogic method
private void onPageSelectedLogic(int position) {
// Check the type of the fragment editable vs button
if(!mPagerAdpater.isFragmentEdiatable(position)) {
// Close the Keyboard
}
}
And this is how you should implement your PagerAdapter
class CustomPagerAdapter extends FragmentStatePagerAdapter {
private SparseBooleanArray fragmentsEditable = new SparseBooleanArray();
public ScreenSlidePagerAdapter(FragmentManager fm) {
super(fm);
}
#Override
public Fragment getItem(int position) {
Fragment fargment;
// get the fragment
if(some condition) {
// Get an editable fragment
fragmentsEditable.put(position, true);
} else {
fragmentsEditable.put(position, false);
}
return fragment;
}
#Override
public int getCount() {
return NUM_PAGES;
}
public boolean isFragmentEditable(int postion) {
return fragmentsEditable.get(postion);
}
}

Dynamically assign the final NUM_PAGES of viewpager

I got the screenslider to work from the android Screenslider,
put a webview in and got it to load the urls i assign to it.
It works fine but now i'd like to control the private static final int NUM_PAGES = 5;
and dynamically change it from a sqlite database numrowcount when i move to this activity.
I tried wrappers and then some but it will crash everytime.
My knowledge of java is somewhat limited elas.
Now i know this works in the oncreate
Bundle bundle = new Bundle();
bundle.putString("urlData", urlData);
ScreenSlidePageFragment fragobj = new ScreenSlidePageFragment();
fragobj.setArguments(bundle);
So i assign the url thats being used to get content within the fragment.
Now how do i control the private static final int NUM_PAGES = 5,
and reassign it to whatever number i want or get from the database?
I just cant get why this is such a difficult thing to create
or find on the web.
Seems to me it should be a non final static number.
I know i am totaly not getting it, but someone does ;)
Anybody any idea?
this is the code:
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
...
public class ScreenSlidePagerActivity extends FragmentActivity {
/**
* The number of pages (wizard steps) to show in this demo.
*/
private static final int NUM_PAGES = 5;
private ViewPager mPager;
private PagerAdapter mPagerAdapter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_screen_slide);
// Instantiate a ViewPager and a PagerAdapter.
mPager = (ViewPager) findViewById(R.id.pager);
mPagerAdapter = new ScreenSlidePagerAdapter(getSupportFragmentManager());
mPager.setAdapter(mPagerAdapter);
}
#Override
public void onBackPressed() {
if (mPager.getCurrentItem() == 0) {
// If the user is currently looking at the first step, allow the system to handle the
// Back button. This calls finish() on this activity and pops the back stack.
super.onBackPressed();
} else {
// Otherwise, select the previous step.
mPager.setCurrentItem(mPager.getCurrentItem() - 1);
}
}
/**
* A simple pager adapter that represents 5 ScreenSlidePageFragment objects, in
* sequence.
*/
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
public ScreenSlidePagerAdapter(FragmentManager fm) {
super(fm);
}
#Override
public Fragment getItem(int position) {
return new ScreenSlidePageFragment();
}
#Override
public int getCount() {
return NUM_PAGES;
}
}
}
Mm i turn out to be easy just make it non final and slip in a variable (int count) with the constructor.
public class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter {
public int NUM_COUNT;
#Override
public int getCount() {
return NUM_COUNT;
}
public ScreenSlidePagerAdapter(FragmentManager fm,int count) {
super(fm);
this.NUM_COUNT = count;
}
#Override
public Fragment getItem(int position) {
return ScreenSlidePageFragment.create(position);
}
}

Block page swipe in a view pager programmatically

I am developing an app where the user can type in stuff in edittexts and get to the next view by swiping the screen. The swiping-stuff is handled by a viewpager.
What I want to do is the following:
The user should only be able to swipe when all edittexts are filled. Currently all my edittexts have a TextWatcher whichs sets a boolean value to "true" once every field is filled. When it is true, I want to enable the viewpager, when it isn't, I want to disable it.
I'm using a CustomViewPager with three Fragments. I post my CustomViewPager code:
import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.widget.Toast;
public class CustomViewPager extends ViewPager {
private boolean isPagingEnabled;
public Context context;
public CustomViewPager(Context context, AttributeSet attrs) {
super(context, attrs);
this.isPagingEnabled = true;
this.context = context;
}
#Override
public boolean onTouchEvent(MotionEvent event) {
if (isPagingEnabled) {
return super.onTouchEvent(event);
}
Toast.makeText(context, "Please fill in the details, then swipe !",
Toast.LENGTH_LONG).show();
return false;
}
#Override
public boolean onInterceptTouchEvent(MotionEvent event) {
if (isPagingEnabled) {
return super.onInterceptTouchEvent(event);
}
return false;
}
public void setPagingEnabled(boolean b) {
isPagingEnabled = b;
}
}
PageViewActivity.java
public class PageViewActivity extends FragmentActivity {
MyPageAdapter pageAdapter;
int pageId=0;
public static CustomViewPager pager;
PageListener pageListener;
int currentPage=0;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
List<Fragment> fragments = getFragments();
pageAdapter = new MyPageAdapter(getSupportFragmentManager(), fragments);
pager =(CustomViewPager)findViewById(R.id.viewpager);
pager.setAdapter(pageAdapter);
pager.setPagingEnabled(false);
pageListener = new PageListener();
pager.setOnPageChangeListener(pageListener);
}
private List<Fragment> getFragments(){
List<Fragment> fList = new ArrayList<Fragment>();
fList.add(MyFragmentA.newInstance("Fragment 1"));
fList.add(MyFragmentB.newInstance("Fragment 2"));
fList.add(MyFragmentC.newInstance("Fragment 3"));
return fList;
}
public void next(View v){
if(pageId<=2)
{
pager.setCurrentItem(pageId);
}
pageId++;
}
private class PageListener extends SimpleOnPageChangeListener{
public void onPageSelected(int position) {
Log.i("test", "onPageSelected " + position);
currentPage = position;
}
//Called when the scroll state changes.
public void onPageScrollStateChanged(int state)
{
}
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels)
{
Log.i("test", "onPageScrolled " + position);
currentPage = position;
}
}
}
My Page Adapter is this:
import java.util.List;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.widget.Toast;
class MyPageAdapter extends FragmentPagerAdapter {
private List<Fragment> fragments;
public MyPageAdapter(FragmentManager fm, List<Fragment> fragments) {
super(fm);
this.fragments = fragments;
}
#Override
public Fragment getItem(int position) {
return this.fragments.get(position);
}
#Override
public int getCount() {
return this.fragments.size();
}
}
Finally I post one of my Fragments with the only relevant code:
public class MyFragmentA extends Fragment {
EditText editname;
public static final String EXTRA_MESSAGE = "EXTRA_MESSAGE";
public static final MyFragmentA newInstance(String message)
{
MyFragmentA f = new MyFragmentA();
Bundle bdl = new Bundle(1);
bdl.putString(EXTRA_MESSAGE, message);
f.setArguments(bdl);
return f;
}
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View myFragmentView = inflater.inflate(R.layout.fragment_a, container, false);
editname = (EditText)myFragmentView.findViewById(R.id.name_input);
editname.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
if(editname.getText().toString().trim().length() == 0) {
// Can I set here isPagingEnabled = false??
Toast.makeText(getActivity(), "SwipeFlag false!", Toast.LENGTH_SHORT).show();
} else if(editname.getText().toString().trim().length() > 0) {
// Can I set here isPagingEnabled = true??
Toast.makeText(getActivity(), "SwipeFlag true!", Toast.LENGTH_SHORT).show();
}
}
});
return myFragmentView;
}
}
I know that the keypoint to block page swipe is to set the flag "isPagingEnabled" to false, but I can't understand what is the best way to set it from a Fragment at runtime.
Ok, I finally found a solution and I post it here.. The best way to block page swipe is to control if edit text is filled inside onPageScrolled in PageViewActivity.java (my MainActivity..):
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
Log.i("test", "onPageScrolled - position = " + position);
currentPage = position;
txt1 = (EditText) findViewById(R.id.name_input);
if(position == 0) {
if(txt1.getText().toString().trim().length() == 0) {
pager.setCurrentItem(0);
} else if(txt1.getText().toString().trim().length() > 0) {
// DO NOTHING
}
}
}
In that way page swipe is not allowed until the edittext field of your fragment is filled.
Another wise way to block page swipe, but ONLY in the right direction is to modify onPageSelected in this way:
boolean inibitFlag = false;
int maxAllowedPage = 1; // .. or you can set this value in your fragment..
public void onPageSelected(int position) {
Log.i("test", "onPageSelected " + position);
if(inibitFlag)
return;
if(position > maxAllowedPage) {
inibitFlag = true;
pager.setCurrentItem(currentPage);
inibitFlag = false;
} else {
currentPage = position;
}
}
Hope this helps someone!!

Categories

Resources