Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9202955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:22:17+00:00 2026-06-17T23:22:17+00:00

I have a little Problem: i have a ViewPager with some Pages and i

  • 0

I have a little Problem: i have a ViewPager with some Pages and i use the FragmentStatePagerAdapter to handle the data. In portrait i have for example 20 pages for the ViewPager and in landscape i have just 10 pages for the ViewPager. So on a orientation change i create a new Adapter with different Data.

Here a little explanation why: I show one image in portrait and two in landscape but always all in count. If i have 10 pictures to show, i have 10 in portrait and 5 in landscape (always two).

But now i have a strange bug:
When i am in Landscape on index 5 and turn the device, the ViewPager’s current page is set to 10. If i turn it back again i am on page 5. If i swipe the ViewPage now to page 10 the methode getItem of the adapter is never called and the ViewPage shows me the one portrait picture and not the two for landscape.
How can this happen? Is there a cache in the adapter or ViewPager? In the onCreate of the Activity everything is new created, the adapter and also the data (just strings with path) for the ViewPager.
So any idea how to fix this really scary “feature”?

Here are some code:

onCreate:

    mViewPagerAdapter = new ReaderPageViewAdapter(getSupportFragmentManager(), getBaseContext(), mCurrentDocument.mPages, getResources()
                .getConfiguration().orientation);
    mPageReader = (ReaderViewPager) findViewById(R.id.pager);
    mPageReader.setAdapter(mViewPagerAdapter);

adapter getItem:

    public Fragment getItem(final int index) {
        final PageInfo pageInfo = mPages.get(index);
        final PageFragment pageFragment = (PageFragment) PageFragment
                .instantiate(mContext, pageInfo.mClss.getName(), pageInfo.mArgs);
        return pageFragment;
    }

If you need something more just tell me. Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:22:19+00:00Added an answer on June 17, 2026 at 11:22 pm

    You can override the FragmentActivity onSaveInstanceState() and not call the super.onSaveInstanceState() in the method.

    @Override
    protected void onSaveInstanceState(final Bundle outState) {
        // super.onSaveInstanceState(outState);
    }
    

    Do not use mViewPager.setSaveEnabled(false);

    it ended up with a big memoryLeak. After every change of the orientation it puts the Fragments into an array of FragmentManager and never cleaned it. So it goes up to over 100mb memory usage after change the orientation many times. Using the onSaveInstanceState method is a better way I think.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have little problem. I can't use AcceptVerb.Get on some ASP.NET MVC actions because
I have little unusual problem to solve. I need some hint or links to
I have a little problem, i have these parameters: df <- data.frame(Equip = c(1,1,1,1,1,2,2,2,2,2),
I have little problem with printing data like this, I have written script like
I have a little problem. I use a direct link to connect to my
I have little problem. In first method of my code I've loaded data about
I'm have little problem in retrieving the data from a table here's the code:
I have a little problem with a FileReference which I use to let users
i have little problem with boost::asio library. My app receive and process data asynchronously,
I have little problem that I have been trying to solve for some time.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.