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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T10:53:43+00:00 2026-05-30T10:53:43+00:00

i am trying to load the list of items from arrays… i get runtime

  • 0

i am trying to load the list of items from arrays… i get runtime error

02-22 11:22:51.042: E/AndroidRuntime(1460): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is ‘android.R.id.list’

my R.java file

public final class R {
    public static final class attr {
    }
    public static final class drawable {
        public static final int ic_launcher=0x7f020000;
        public static final int icon=0x7f020001;
    }
    public static final class id {
        public static final int mylist=0x7f050000;
        public static final int next=0x7f050005;
        public static final int play=0x7f050004;
        public static final int prev=0x7f050003;
        public static final int seekbar=0x7f050002;
        public static final int selectedfile=0x7f050001;
        public static final int text1=0x7f050006;
    }
    public static final class layout {
        public static final int audiolist=0x7f030000;
        public static final int song_item=0x7f030001;
        public static final int songlist=0x7f030002;
    }
    public static final class string {
        public static final int app_name=0x7f040000;
    }
}

my code:

@Override
public void onCreate(Bundle icicle) {
    try {
        super.onCreate(icicle);
      setContentView(R.layout.audiolist);

        ListView listView = (ListView) findViewById(R.id.mylist);
    String[] values = new String[] { "Android", "iPhone", "WindowsMobile"};
    ArrayAdapter<String> spinnerArrayAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, values);
listView.setAdapter(spinnerArrayAdapter);

    } catch (NullPointerException e) {
        Log.v(getString(R.string.app_name), e.getMessage());
    }
}

layout: audiolist

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

    <ListView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
         android:id="@+id/mylist"
        android:layout_weight="1.0"/>

    <LinearLayout
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:background="@android:drawable/screen_background_light"
        android:padding="10dip">

        <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/selectedfile"
            android:text="Not file selected"
            android:textColor="@android:color/black"
            android:gravity="center_horizontal"
            android:singleLine="true"
            android:ellipsize="middle"/>

        <SeekBar
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:id="@+id/seekbar"
            android:max="100"
            android:paddingBottom="10dip"/>

        <LinearLayout
            android:orientation="horizontal"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:gravity="center"
            android:background="@android:drawable/screen_background_light">

            <ImageButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/prev"
                android:src="@android:drawable/ic_media_previous"/>

            <ImageButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/play"
                android:src="@android:drawable/ic_media_play"/>

            <ImageButton
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/next"
                android:src="@android:drawable/ic_media_next"/>

        </LinearLayout>
    </LinearLayout>

</LinearLayout>
  • 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-30T10:53:45+00:00Added an answer on May 30, 2026 at 10:53 am

    From the reference

    ListActivity has a default layout that consists of a single,
    full-screen list in the center of the screen. However, if you desire,
    you can customize the screen layout by setting your own view layout
    with setContentView() in onCreate(). To do this, your own view MUST
    contain a ListView object with the id “@android:id/list” (or list if
    it’s in code)

    You ll either have to change the listview's id to that default or you need to use setContentView(...)

    Update: Code sample

    You can check the tutorial of Vogella, it s a great one showing u step by step. You cannot fail.

    Update 2 Possible solution
    My last guess is that your activity extends ListActivity so the builder is looking for a default list as the layout. IF so, use simple Activity instead and see the answer to this question: How can I implement a ListView without ListActivity? (use only Activity)

    Good luck

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

Sidebar

Related Questions

I am trying to load a list of items from a Magento model. What
I am trying to load a list of ordered items from the server and
I'm a tad stuck trying to get a List to load from the ViewState
I'm trying to load File.ServerRelativeUrl when loading items from list, but no luck. Trying
I'm trying to load a list of filenames from a text file and then
hello i am trying to load a list of filenames from a folder into
I have a javascript code, whereby I'm trying to load a list from a
trying to load in a bunch of images into a list from a directory...my
I am trying to retrieve a list of dropdown items from the database. The
i'm trying hard to load comboBox items from an xml file. Here is my

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.