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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:57:10+00:00 2026-06-09T06:57:10+00:00

I am playing around with ListView in android and I have a simple class

  • 0

I am playing around with ListView in android and I have a simple class that extends ListActivity.

Whenever I change the name of the ListView in xml file from android:list to something else my program crashes.

Here is my ListActivity code:

private NewExpenseScreenModel mDbAdabter;

    String[] items = { "Category", "Month", "Year"};
       /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.statistics);

        Spinner spinner = (Spinner) findViewById(R.id.spinner);

        ArrayAdapter adapter = new ArrayAdapter(
                this,
                android.R.layout.simple_spinner_item, 
                items);

        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        spinner.setAdapter(adapter);
        mDbAdabter = new NewExpenseScreenModel(this);

        populateFields();


    }

    private void populateFields() 
    {
        ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.spending_row, mDbAdabter.getAllCategories());
        setListAdapter(adapter);
    }

and here is my xml file:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:padding="10dip"
   android:layout_width="fill_parent"
   android:layout_height="wrap_content">

    <Spinner
       android:id="@+id/spinner"
       android:layout_width="fill_parent"
       android:layout_height="wrap_content"
       android:prompt="@string/spinner_title"
   />
    <ListView android:id="@+id/android:list" android:layout_height="wrap_content"  android:layout_width="match_parent"></ListView>
</LinearLayout>

any idea what is going on..
I want to implement a onItemClickedListener later on so I want to be able to find the ListView by id.
I dont really understand why i cannot just change the id

Additional Info:

I also have another class that uses a different xml file with a list id=”android:list” but I never need to find that listView by id so its not a problem.
The other class uses the same xml file to describe layout of each row.

Update:

I managed to access the id by using findViewById(android.R.id.list); instead of findViewById(R.id.list); but i still dont understand why it wont let me rename the list

  • 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-09T06:57:12+00:00Added an answer on June 9, 2026 at 6:57 am

    The list view id should be @android:id/list.

    You use + in id when you define a new id. Since you are using ListView id of the listview should have list and list id is already defined internally, so no need to add +.

    Edited

    The above is mandatory when you extend the class from ListActivity. See @Mejonzhan answer why so.

    Now, if you want your own id or when you want to have many List Views, then do not extend ListActivity instead extend Activity and handle the ListViews as below:

    Change id as follows:

    <ListView android:id="@+id/myListView"

    And in the code, access the list view as follows:

    ListView myListView = (ListView) findViewById(R.id.myListView)

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

Sidebar

Related Questions

I've been playing around with Simple.Data and have run across something that I can't
playing around with a property file i figured that there seems to be a
Android-newbie playing around with a SimpleCursorAdapter and I've run into a few problems that
I'm playing around with wpf and I saw the following article: WPF ListView Inactive
Playing around with MongoDB and NoRM in .NET. Thing that confused me - there
Was playing around a little bit with the TimeSpan class and I started wondering
So I am playing around with using a ListView instead of a GridView to
While playing around with playframework yabe-siena-gae, I noticed a datastore file created for the
While playing around with the emulator, I noticed that when trying to view a
I have been playing around with various methods of making the Visitor pattern in

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.