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 7064889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:53:22+00:00 2026-05-28T04:53:22+00:00

Hopefully someone can help me with a slight problem/confusion I have with Viewpagers and

  • 0

Hopefully someone can help me with a slight problem/confusion I have with Viewpagers and saving data.

PROBLEM:

When scrolling across the four views I have, the first view has two spinners, two textviews that display a string or a selected item. if I scroll on to the third page and back to the second page, the data in the first view is lost. hense needing to save the data.

Would this be done in the two routines stated below? (best guess is it would be) if so, what sort of commands need to be stated?

CODE:

@Override   
public void restoreState(Parcelable arg0, ClassLoader arg1) {       
}

@Override
public Parcelable saveState() {
    return null;
}

EXTRA INFO:
the viewpager is being used in

public Object instantiateItem(View collection, int position) {
}

The complete list of methods are as follows:

@Override
public void destroyItem(View arg0, int arg1, Object arg2) {
    ((ViewPager) arg0).removeView((View) arg2);
}

@Override
public boolean isViewFromObject(View arg0, Object arg1) {
    return arg0 == ((View) arg1);
}

@Override
public Parcelable saveState() {
    return null;
}

@Override
public void finishUpdate(View arg0) {
}

@Override
public void restoreState(Parcelable arg0, ClassLoader arg1) {
}

@Override
public void startUpdate(View arg0) {
}
  • 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-05-28T04:53:22+00:00Added an answer on May 28, 2026 at 4:53 am

    Instead of saving the state of those pages you could modify your ViewPager so it buffers all of your pages instead of destroying them and recreating them when you scroll.

    So for example if you have 4 pages:

    ViewPager pager = (ViewPager) findViewById(R.id.viewpager);
    pager.setOffscreenPageLimit(3); // the number of "off screen" pages to keep loaded each side of the current page
    pager.setAdapter(new PageAdapter(context));
    

    Now your pages will be kept ‘alive’

    Be careful with this technique however because it will increase memory consumption. The number passed to setOffscreenPageLimit() is the number of pages each side of the current page to retain. In this case we have 4 pages in total so the worst case scenario is when we are at the far edge of of the page set – we have the currently visible page and then the remaining 3 pages are off screen to one side and are thus kept in memory. However, with a larger data set it could potentially mean 7 pages are kept in memory (current page plus 3 either side).

    Generally the more optimal solution would be to properly deal with unloading and reloading the page state and re-render them.

    Hope this helps

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

Sidebar

Related Questions

hopefully someone can help me with this odd problem. I have a database which
Hopefully someone can help here, it's incredibly frustrating! I have a couple of iOS
Hopefully someone can help here. I have a ListView that is populated by a
everyone! i have a question about sessions hopefully someone can help me with. I
Hopefully someone can help me with this problem. I'm starting to work with Drupal
Quite a simple one I think, but hopefully someone can help out. I have
hopefully someone can help me with this headache I have. I'm currently running Drupal
I have another beginner's question that hopefully someone can help with. I'm trying to
Hopefully someone can help me debug this problem as EXC_BAD_ACCESS is the only error
I have some funny (?!?) issues with the DateTimePicker and hopefully someone can help

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.