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

  • Home
  • SEARCH
  • 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 8903401
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:51:42+00:00 2026-06-15T01:51:42+00:00

I’m a noob to Android development and I am having a bit of an

  • 0

I’m a noob to Android development and I am having a bit of an issue showing a preference screen in viewpager. Currently, my app is showing all the pages of the viewpager jumbled up as one page with the preference screen serving as the background. Then, when i gesture, the app crashes due to an InflateException. I have researched the potential causes with the SO questions here and here but none offer solutions that rectify my issue. I would just use Preference fragment, but I’m developing for min 8 API. Any help is greatly appreciated.

MY CODE

public class Options extends PreferenceActivity implements OnClickListener   ,SharedPreferences.OnSharedPreferenceChangeListener{

ActionBarSherlock mSherlock = ActionBarSherlock.wrap(this);
View view;

@Override
public void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.Theme_Sherlock);
    super.onCreate(savedInstanceState);

   addPreferencesFromResource(R.xml.prefs);
   PreferenceManager.getDefaultSharedPreferences(this).registerOnSharedPreferenceChangeListener(this);

    mSherlock.setContentView(R.layout.options);

MyPagerAdapter adapter = new MyPagerAdapter(this);
ViewPager myPager = (ViewPager) findViewById(R.id.viewpager);
myPager.setAdapter(adapter);
myPager.setCurrentItem(2);
TitlePageIndicator indicator = (TitlePageIndicator)findViewById( R.id.indicator ); 
indicator.setViewPager( myPager );
indicator.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
    @Override
    public void onPageSelected(int position) {

          if(position == 0 ||position == 1||position == 2||position == 4){

          }
    }

    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
    }

    @Override
    public void onPageScrollStateChanged(int state) {
    }
});  
}

private class MyPagerAdapter extends PagerAdapter {

    private String[] titles = new String[] {"HELP",  "PREFERENCES", "ABOUT" };
private final Context context;
private int[] scrollPosition = new int[titles.length];

public MyPagerAdapter( Context context )
{
    this.context = context;
    for ( int i = 0; i < titles.length; i++ )
    {
        scrollPosition[i] = 0;
    }
}

@Override
public String getPageTitle( int position )
{
    return titles[position];
}

@Override
public int getCount()
{
    return titles.length;
}



    public Object instantiateItem(View collection, int position) {

        LayoutInflater inflater = (LayoutInflater) collection.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);


        int resId = 0;
        switch (position) {
        case 2:
            resId = R.layout.help;              
            view = inflater.inflate(resId, null);
            LinearLayout layout0=(LinearLayout)view.findViewById(R.id.helplayout);
            ((ViewPager) collection).addView(view, 0);
            return view;

        case 0:
            resId = R.xml.prefs;
            view = inflater.inflate(resId, null);
            LinearLayout layout1=(LinearLayout)view.findViewById(R.id.RLcoins);


            ((ViewPager) collection).addView(view, 0);
            return view;

        case 1:
            resId = R.layout.about;
            view = inflater.inflate(resId, null);
            LinearLayout layout2=(LinearLayout)view.findViewById(R.id.LLtwitter);


            ((ViewPager) collection).addView(view, 0);
            return view;



        }
        return resId;

    }

MY LOGCAT

11-27 16:00:50.039: E/AndroidRuntime(3993): FATAL EXCEPTION: main
11-27 16:00:50.039: E/AndroidRuntime(3993): android.view.InflateException: Binary XML file line #2: Error inflating class PreferenceScreen
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at com.bryanjrichardson.GSCC.Options$MyPagerAdapter.instantiateItem(Options.java:130)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.support.v4.view.PagerAdapter.instantiateItem(PagerAdapter.java:110)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.support.v4.view.ViewPager.addNewItem(ViewPager.java:692)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.support.v4.view.ViewPager.populate(ViewPager.java:849)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.support.v4.view.ViewPager.populate(ViewPager.java:772)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.support.v4.view.ViewPager.completeScroll(ViewPager.java:1539)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.support.v4.view.ViewPager.computeScroll(ViewPager.java:1422)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.ViewGroup.drawChild(ViewGroup.java:1562)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.ViewGroup.drawChild(ViewGroup.java:1644)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1373)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.View.draw(View.java:6883)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.widget.FrameLayout.draw(FrameLayout.java:357)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:2116)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.ViewRoot.draw(ViewRoot.java:1565)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.ViewRoot.performTraversals(ViewRoot.java:1301)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1914)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.os.Handler.dispatchMessage(Handler.java:99)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.os.Looper.loop(Looper.java:130)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.app.ActivityThread.main(ActivityThread.java:3859)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at java.lang.reflect.Method.invokeNative(Native Method)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at java.lang.reflect.Method.invoke(Method.java:507)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at dalvik.system.NativeStart.main(Native Method)
11-27 16:00:50.039: E/AndroidRuntime(3993): Caused by: java.lang.ClassNotFoundException: android.view.PreferenceScreen in loader dalvik.system.PathClassLoader[/system/framework/com.google.android.maps.jar:/data/app/com.bryan.GSCC-1.apk]
11-27 16:00:50.039: E/AndroidRuntime(3993):     at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.LayoutInflater.createView(LayoutInflater.java:471)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:549)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
11-27 16:00:50.039: E/AndroidRuntime(3993):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
  • 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-15T01:51:43+00:00Added an answer on June 15, 2026 at 1:51 am

    You should use fragments for help/about and a PreferenceFragment for the preferences.

    Here’s a tutorial for PreferenceFragment
    http://android-er.blogspot.com.ar/2012/07/example-of-using-preferencefragment.html

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I am currently running into a problem where an element is coming back from
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am writing an app with both english and french support. The app requests

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.