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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:44:25+00:00 2026-06-02T10:44:25+00:00

I have an application which uses ViewPager. Inside the ViewPager I don’t use Fragments,

  • 0

I have an application which uses ViewPager. Inside the ViewPager I don’t use Fragments, just inflated views (a RelativeLayout with some content). These views are pre-created and held in a List. I created simple PagerAdapter implementation which overrides methods getCount, isViewFromObject, instantiateItem and destroyItem.

When running on Android 2.x device it all runs fine and the method instantiateItem is called just once for each page that gets loaded as an offscreen page.

But when I run on ICS, the instantiateItem method gets called in a loop and the whole application stops responding. All I was able to realize was, that the instantiateItem method gets called as a result of a measurement. But I have no clue why on ICS the measurement gets called periodically in a loop and what can I do to stop it.

Here is a code snippet, but I believe there’s nothing special on it:

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

        @Override
        public int getCount()
        {
            return mPages.size();
        }

        @Override
        public Object instantiateItem(ViewGroup container, int position)
        {
            View v = mPages.get(position);
            boolean isChild = false;
            for(int idx = 0; idx < getChildCount(); ++idx)
            {
                if(getChildAt(idx) == v)
                {
                    isChild = true;
                    break;
                }
            }
            if(!isChild)
                addView(v);
            return v;
        }

        @Override
        public void destroyItem(ViewGroup container, int position, Object item)
        {
            removeView((View)item);
        }

    };
    setAdapter(mAdapter);

This code gets place in an initialization method of a class which derives from ViewPager.

I would really appreciate any hint, because this issue is driving me crazy and makes my application unusable on ICS devices.

  • 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-02T10:44:26+00:00Added an answer on June 2, 2026 at 10:44 am

    The answer is hidden in application localization – I override Application.onConfigurationChange and set new default Locale and update configuration with this new Locale.

    This is a recommended approach for forcing the application’s Locale, but on ICS it caused my activity containing ViewPager to be recreated regularly when switched to landscape orientation.

    If you ever meet this situation I recommend to override Activity.onConfigurationChange instead of Application’s method. For some reason it works fine on ICS.

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

Sidebar

Related Questions

I have an application which uses some Tabs. The functionality of these tabs is
I have application which uses fragments. Depending on screen size and orientation I'm displaying
I have one application which uses the standard .NET forms authentication cookie, now I
I have an application which uses JSPs and Servlets and deployed on IBM-WASCE 2.1.
I have an Android application which uses the NDK to execute a large amount
I have a little application which uses regular expressions under VB6. It works perfectly
I have a window application which uses SP classes to create a site. I
I have made an application which uses latest ios facebook sdk to connect. I
I have an IOS application which uses environment variables and am able to set
I have a PHP web application which uses a MySQL database for object tagging,

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.