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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:39:18+00:00 2026-05-27T19:39:18+00:00

I am getting an error in my logcat saying Your content must have a

  • 0

I am getting an error in my logcat saying “Your content must have a ListView whose id attribute is ‘android.R.id.list'”. My code compiles and runs but force closes when I start my listview activity. I’ve checked on many similar questions, it seems to be a common problem but I am still unable to fix my code.

The Declaration:

    private ListView lv;
    Context mContext;
    List mList;
    String[] testcontacts;

    MessageView aa = null;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.firstlist);
        testcontacts = getResources()
                .getStringArray(R.array.testcontacts_array);

        aa = new MessageView();
        lv = getListView();/*(ListView) lv.findViewById(R.id.list); Had to comment out, it cannot find list*/
        lv.setAdapter(aa);
        lv.setTextFilterEnabled(true);

        lv.setOnItemClickListener(new OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View view,
                    int position, long id) {
                // When clicked, show a toast with the TextView text
                Toast.makeText(getApplicationContext(),
                        ((TextView) view).getText(), Toast.LENGTH_SHORT).show();
            }
        });
    }
class MessageView extends ArrayAdapter<String> {
        MessageView() {
            super(FirstLoginActivity.this, android.R.layout.activity_list_item,
                    testcontacts);
            // TODO Auto-generated constructor stub
        }

        public View getView(int position, View convertview, ViewGroup parent) {
            Log.d("Ebz", "inside getView method");
            ViewHolder holder;
            View v = convertview;
            if (v == null) {
                Log.d("Ebz", "if v == null");
                LayoutInflater inflater = getLayoutInflater();
                v = inflater.inflate(R.layout.list_items, null);
                holder = new ViewHolder();
                holder.firstLine = (TextView) v.findViewById(R.id.firstLine);
                holder.secondLine = (TextView) v.findViewById(R.id.secondLine);
                holder.icon1 = (ImageView) v.findViewById(R.id.icon1);
                holder.icon2 = (ImageView) v.findViewById(R.id.icon2);
                v.setTag(holder);
            } else {
                holder = (ViewHolder) v.getTag();
            }
            holder.firstLine.setText(testcontacts[position]);
            holder.secondLine.setText(testcontacts[position]);
            holder.icon1.setImageBitmap(null);
            holder.icon2.setImageBitmap(null);
            // call the images directly?
            return v;
        }

        class ViewHolder {
            TextView firstLine;
            TextView secondLine;
            ImageView icon1;
            ImageView icon2;

        }
    }
}

My XML

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

    <RelativeLayout
        android:id="@+id/top_control_bar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >

        <TextView
            android:id="@+id/textView1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_weight="1"
            android:background="#cc252a"
            android:paddingBottom="10dp"
            android:paddingLeft="10dp"
            android:paddingTop="10dp"
            android:text="This will be Changed"
            android:textAppearance="?android:attr/textAppearanceLarge" />
    </RelativeLayout>

    <LinearLayout
        android:id="@+id/bottom_control_bar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >
    </LinearLayout>

    <ListView
        android:id="@+id/list"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_above="@id/bottom_control_bar"
        android:layout_below="@id/top_control_bar"
        android:choiceMode="multipleChoice" />

</RelativeLayout>

My ListItems:

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

    <RelativeLayout
        android:id="@+id/top_control_bar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >


        <TextView
            android:id="@+id/textView1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginBottom="10dp"
            android:layout_weight="1"
            android:background="#cc252a"
            android:paddingBottom="10dp"
            android:paddingLeft="10dp"
            android:paddingTop="10dp"
            android:text="This will be Changed"
            android:textAppearance="?android:attr/textAppearanceLarge" />

    </RelativeLayout>

    <LinearLayout
        android:id="@+id/bottom_control_bar"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true" >
    </LinearLayout>

    <ListView
        android:id="@+id/list"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_above="@id/bottom_control_bar"
        android:layout_below="@id/top_control_bar"
        android:choiceMode="multipleChoice"
        android:divider="#cc252a"
        android:dividerHeight="14.5dp" />

</RelativeLayout>
  • 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-05-27T19:39:19+00:00Added an answer on May 27, 2026 at 7:39 pm

    You are probably using a ListActivity.

    In you firstlist.xml replace the id to:

    <ListView
        android:id="@android:id/list"
    ...
    

    ListActivity looks for the id R.android.id.list which you in xml is @android:id/list.


    Also look at this post: ListView whose id attribute is 'android.R.id.list' Error when I have the ListView id set correctly

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

Sidebar

Related Questions

In Android Emulator i am getting below Logcat Error: 03-11 04:44:56.663: ERROR/AndroidRuntime(403): java.lang.RuntimeException: Unable
I am getting error trying to run my asp code for executing stored proc.
I wrote following code...but i am getting Error like: Error 1 'LoginDLL.Class1.Login(string, string, string)':
hi im new to c# and was trying to code but getting error can
hi i hav a code like this in the end i m getting error
With the following code, I keep getting error C2535 when I compile. It's complaining
im getting an error from logcat: 01-13 17:53:25.368: E/AndroidRuntime(3235): Caused by: java.lang.NullPointerException 01-13 17:53:25.368:
I can't figure out why I'm getting this error in logcat: 02-14 15:44:42.470: E/ActivityThread(32164):
I am getting an error in my code while i try to show the
I am getting the IllegalAccessError while running Android instrumentation tests. This is Logcat output:

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.