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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:06:27+00:00 2026-06-14T22:06:27+00:00

I have a very basic application in which I am trying to create ListFragment

  • 0

I have a very basic application in which I am trying to create ListFragment on the MainActivity.

I keep on getting the following runtime error:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.proto1.listfragment/com.proto1.listfragment.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class fragment

I have two classes.

The first is MainActivity.java as shown below:

package com.proto1.listfragment;

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.Menu;

public class MainActivity extends FragmentActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
}

The second is the class relating to the listfragment SectionsList as shown below:

package com.proto1.listfragment;

import android.os.Bundle;
import android.support.v4.app.ListFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

    public class SectionsList extends ListFragment {

        //Create an array to hold the sections
        String sections [] = new String []{
            "Starters", "Mains", "Sides", "Desserts", "Drinks"
        };

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,Bundle savedInstanceState) {  

            //Create array adapter to store list of menu sections
            ArrayAdapter<String> adapter = new ArrayAdapter<String>(inflater.getContext(), android.R.layout.simple_list_item_1,sections);

            //Set list adapter of fragment
            setListAdapter(adapter);

            return super.onCreateView(inflater, container, savedInstanceState);     
        }

    }

I then have one XML layout file called activity_main as shown below:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:orientation = "horizontal"
android:layout_height="fill_parent" >

<fragment 
    android:name = "com.proto1.listfragment.MainActivity"
    android:id="@+id/sectionFrag"
    android:layout_width = "wrap_content"
    android:layout_height = "fill_parent"/>

<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="@string/hello_world"
    tools:context=".MainActivity" />

I am unable to see why this error is being generated. Can someone please shed some light on the issue? Many 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-14T22:06:28+00:00Added an answer on June 14, 2026 at 10:06 pm

    A FragmentActivity is not a Fragment in itself. But rather, it is a way to easily interact with Fragments. The Fragment you call in your xml should be SectionList.

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

Sidebar

Related Questions

I have a very basic backbone (sample) application which just creates and destroys model
I have a very basic mysql table called memberships, that tracks which people belong
I have a very basic API in my app which also has an index
I'm trying to code a very basic lightmeter application for use with my old
I'm trying to create a web user interface for a Java application. The user
I'm building a solution for a client which allows them to create very basic
I've got a very basic application that boils down to the following code: char*
In my MVC 3 application I have a very basic controller [HttpPost] public ActionResult
I have been trying different techniques while designing this application, which to me is
I have a very basic web crawler. The database table which stores the links

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.