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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T22:50:18+00:00 2026-06-10T22:50:18+00:00

I have issues in displaying ListView inside a Fragment. I am using ListFragment in

  • 0

I have issues in displaying ListView inside a Fragment. I am using ListFragment in my Fragment. I couldn’t able to figure out where my actual issue is.

CategoriesFragment.java

public class CategoriesFragment extends ListFragment {  
ListView lv;
TextView tv;    
  public CategoriesFragment() {
  }    

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {        
    if(container==null)
        return null;
    inflater.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.categories_fragment,container,false);
    View listView = (ListView)view.findViewById(R.id.listview1);
    return view;        
  }    

  @Override
  public void onActivityCreated(Bundle savedInstanceState) {    
    super.onActivityCreated(savedInstanceState);
    final String[] fruits = new String[] { "Apple", "Avocado", "Banana",
        "Blueberry", "Coconut", "Durian", "Guava", "Kiwifruit"};            
    setListAdapter(new ArrayAdapter<String>
        (getActivity(),R.layout.categories_fragment,fruits));       
  }
}

PagerAdaper.java

public class SectionsPagerAdapter extends FragmentPagerAdapter {
  public SectionsPagerAdapter(FragmentManager fm) {
    super(fm);
  }

  @Override
  public Fragment getItem(int i) {
    switch(i) {
     case 0:
      Fragment fragment = new CategoriesFragment(); 
      return fragment;
      break;
     case 1:
      Fragment fragment = new FeaturedFragment(); 
      return fragment;
      break
    }
    return null;
  }

  @Override
  public int getCount() {
    return 2;
  }

  @Override
  public CharSequence getPageTitle(int position) {
    switch (position) {
      case 0: return "CATEGORIES";
      case 1: return "FEATURED";
    }
    return null;
  }
}

categories_fragment.xml

<?xml version="1.0" encoding="utf-8"?>

<ListView xmlns:android="http://schemas.android.com/apk/res/android"
  android:id="@+id/listview1"
  android:layout_width="match_parent"
  android:layout_height="match_parent"/>

DDMS error text:

09-06 12:37:47.402: E/AndroidRuntime(2611): FATAL EXCEPTION: main
09-06 12:37:47.402: E/AndroidRuntime(2611): java.lang.RuntimeException: Your content        must have a ListView whose id attribute is 'android.R.id.list'
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.support.v4.app.ListFragment.ensureList(ListFragment.java:344)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.support.v4.app.ListFragment.onViewCreated(ListFragment.java:145)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:885)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1083)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:635)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1431)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:431)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:141)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.support.v4.view.ViewPager.populate(ViewPager.java:895)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.support.v4.view.ViewPager.populate(ViewPager.java:772)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1234)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.view.View.measure(View.java:12723)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1369)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:1017)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:555)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.view.View.measure(View.java:12723)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.view.View.measure(View.java:12723)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:812)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:553)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.view.View.measure(View.java:12723)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
09-06 12:37:47.402: E/AndroidRuntime(2611):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
  • 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-10T22:50:20+00:00Added an answer on June 10, 2026 at 10:50 pm

    Change this

    <ListView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/listview1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>
    

    to,

    <ListView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/list"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>
    

    The problem is with the ID. When you extend ListFragment your ListView must have id something like this, @android:id/list

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

Sidebar

Related Questions

We have issues within an application using a state machine. The application is implemented
I am trying to figure out the best method of displaying a json result
I'm having issues with some jQuery code I have. Using $.each I am looping
As described above, I have issues with @font-face not displaying in IE9 although it
Having issues with screen progress. I have a screen displaying information from a database.
I have created listview using layoutinflator. Listview contains checkbox and textview for each row.
I have issues with Firefox and keydown function. It will not trigger the function
I have issues with .NET CF 3.5 application on Windows Mobile 6.5 on Motorola
I have issues with NSUserDefaults and I don't quite understand what is going on.
I still have issues reading UML diagrams. Just looking at the Builder pattern http://en.wikipedia.org/wiki/Builder_pattern

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.