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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T15:11:45+00:00 2026-06-16T15:11:45+00:00

1- I want to use ListFragment. 2 – My class extends from Activity not

  • 0

1- I want to use ListFragment.

2 – My class extends from Activity not a ListActivity (because I want to have a TextView at the top of ListView). as a result this is the main layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
            android:id="@+id/txt"
            android:layout_width="fill_parent"
            android:layout_height="40sp" />

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

</LinearLayout>

And this my code:

public class List1 extends SherlockListFragment {

    private ArrayList<String> list = new ArrayList<String>();

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        System.out.println("onCreate............");

        for(int i=0; i<30; i++)
            list.add("item " + i);
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        System.out.println("onCreateView.................");

        View view = inflater.inflate(R.layout.main_list1, container, false);

        TextView label = (TextView) view.findViewById(R.id.txt);
        label.setText("Hello");

        ListView lv = (ListView) view.findViewById(R.id.listView);
          lv.setAdapter(new MultiAdapter(view.getContext()));

        return view;
    }

    @Override 
    public void onActivityCreated(Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        System.out.println("onActivityCreated..........");


    }

    private class MultiAdapter extends ArrayAdapter<String> {

        public MultiAdapter(Context context) {
            super(context, R.layout.list1, list);
        }

        @Override
        // Called when updating the ListView
        public View getView(int position, View convertView, ViewGroup parent) {

            View row;

            if (convertView == null)  {
                LayoutInflater inflater = getActivity().getLayoutInflater();
                row = inflater.inflate(R.layout.list1, parent, false);
            } else
                row = convertView;

            TextView txt = (TextView) row.findViewById(R.id.label);
            txt.setText(list.get(position));    

            return row;
        }
    }

The application crashed when I go to this Fragment using Tab. This is the exception that I got in log:

01-01 14:59:51.154: E/AndroidRuntime(20091): FATAL EXCEPTION: main
01-01 14:59:51.154: E/AndroidRuntime(20091): java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
01-01 14:59:51.154: E/AndroidRuntime(20091):    at android.support.v4.app.ListFragment.ensureList(ListFragment.java:344)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at android.support.v4.app.ListFragment.onViewCreated(ListFragment.java:145)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:884)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:622)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1416)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:431)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at com.example.tabtest.FragmentTab$TabManager.onTabChanged(FragmentTab.java:134)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at android.widget.TabHost.invokeOnTabChangeListener(TabHost.java:359)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at android.widget.TabHost.setCurrentTab(TabHost.java:344)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:132)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:458)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at android.view.View.performClick(View.java:2533)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at android.view.View$PerformClick.run(View.java:9320)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at android.os.Handler.handleCallback(Handler.java:587)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at android.os.Handler.dispatchMessage(Handler.java:92)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at android.os.Looper.loop(Looper.java:150)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at android.app.ActivityThread.main(ActivityThread.java:4385)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at java.lang.reflect.Method.invokeNative(Native Method)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at java.lang.reflect.Method.invoke(Method.java:507)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
01-01 14:59:51.154: E/AndroidRuntime(20091):    at dalvik.system.NativeStart.main(Native Method)
  • 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-16T15:11:46+00:00Added an answer on June 16, 2026 at 3:11 pm

    Your fragment layout must have a ListView with the id: android.R.id.list, otherwise android will not know which ListView to use.

    Like this:

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

    Notice the android:id="@android:id/list".

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

Sidebar

Related Questions

i want use some data from a website with web service. i have a
i have a ListView on a ListFragment that use SimpleCursorAdapter to generate my list.
I want use BYTE_ORDER macro in my Xcode project but i can't because i
We have a powerbuilder application and we want use a scanner through this application
What I want to achieve is having a ListFragment which displays data loaded from
Want use special charecters ex : (£, ¥) which not there in keyboard to
I want use php curl with oauth to get the JSON data from twitter
I want to use hover function with live method but it is not working
I want use localized strings from resources in xsl template as in aspx page,
I want use many bitmap for my game canvas. I can't Recycle bitmaps, because

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.