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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:27:08+00:00 2026-06-15T14:27:08+00:00

I keep getting that error when starting the activity that has fragment. This is

  • 0

I keep getting that error when starting the activity that has fragment.

This is the overview of my code:

Home activity is started from Splash screen activity

home.xml (Each fragment has 50% layout_weight)

<LinearLayout>
    <fragment android:name="com.example.test.FragmentClass1" ...>
    <fragment android:name="com.example.test.FragmentClass2" ...>
</LinearLayout>

fragment1.xml

<LinearLayout>
    //some EditTexts and Buttons here
<LinearLayout>

fragment2.xml

<LinearLayout>
    <ListView ... />
</LinearLayout>

FragmentClass1.java

public class FragmentClass1 extends Fragment{
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
        View view = inflater.inflate(R.layout.fragment1, container, false);
        return view;
    }
}

FragmentClass2.java

public class FragmentClass2 extends ListFragment{
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
        View view = inflater.inflate(R.layout.fragment2, container, false);
        return view;
    }
}

Home.java

public class Home extends Activity{
    public View onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        setContentView(R.layout.home);
        //still empty
    }
}

The error log is this:

12-09 20:39:00.317: E/AndroidRuntime(18214): FATAL EXCEPTION: main
12-09 20:39:00.317: E/AndroidRuntime(18214): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.test/com.example.test.Home}: android.view.InflateException: Binary XML file line #10: Error inflating class fragment
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.os.Handler.dispatchMessage(Handler.java:99)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.os.Looper.loop(Looper.java:137)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.app.ActivityThread.main(ActivityThread.java:5039)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at java.lang.reflect.Method.invokeNative(Native Method)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at java.lang.reflect.Method.invoke(Method.java:511)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at dalvik.system.NativeStart.main(Native Method)
12-09 20:39:00.317: E/AndroidRuntime(18214): Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class fragment
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.app.Activity.setContentView(Activity.java:1881)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at com.example.test.Home.onCreate(Home.java:16)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.app.Activity.performCreate(Activity.java:5104)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
12-09 20:39:00.317: E/AndroidRuntime(18214):    ... 11 more
12-09 20:39:00.317: E/AndroidRuntime(18214): Caused by: java.lang.ClassCastException: com.example.test.Fragment1 cannot be cast to android.app.Fragment
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.app.Fragment.instantiate(Fragment.java:585)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.app.Fragment.instantiate(Fragment.java:560)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.app.Activity.onCreateView(Activity.java:4709)
12-09 20:39:00.317: E/AndroidRuntime(18214):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
12-09 20:39:00.317: E/AndroidRuntime(18214):    ... 21 more

Any solution? 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-15T14:27:09+00:00Added an answer on June 15, 2026 at 2:27 pm

    If you are trying to use the Android Support package’s backport of fragments, you need to have your activity inherit from FragmentActivity (or from something else that inherits from FragmentActivity, like SherlockFragmentActivity).


    UPDATE

    The key line from your stack trace is:

    12-09 20:39:00.317: E/AndroidRuntime(18214): Caused by: java.lang.ClassCastException: com.example.test.Fragment1 cannot be cast to android.app.Fragment
    

    Now, there is nothing in your supplied source code that is named com.example.test.Fragment1. If this is really what you have in your listings as com.example.test.FragmentClass1, then presumably the Fragment you are inheriting from is not android.app.Fragment. Most likely, in that case, it is android.support.v4.app.Fragment — the Fragment class from the backport. If this is the case, change the import statement (and any other flawed ones in the rest of your code base).

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

Sidebar

Related Questions

I've created a singleton class that loads a plist. I keep getting this error
I wrote this Ext js application but I keep getting this error that says
I'm just starting to learn python and keep getting an error that I just
I keep getting a Run Time error that says I am having an Exception
I keep getting an error saying that @android:style/Widget.Holo.Light.Button.Borderless is not public and so can't
I keep getting the error in VS 2100 CRT detected that the application wrote
I'm trying to install a package that uses global-linum-mode and keep getting: error Autoloading
For some reason I keep getting a error that says toupper cannot be used
I'm trying to play with some code..keep getting an compile error RND not declared
I keep getting this error when trying to open a connection using entity framework.

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.