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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:25:00+00:00 2026-06-13T09:25:00+00:00

I have a program that gets a remote xml file and creates a list

  • 0

I have a program that gets a remote xml file and creates a list view in android, i can pull the data from the xml but i cannot seem to place it in the right places. i have a custom layout but its not going in the right fields. how can i accomplish this? here is part of my code. its not working at the moment . thanks – in advance

  // looping through all item nodes <item>
                for (int i = 0; i < nl.getLength(); i++) {
                    // creating new HashMap
                    HashMap<String, String> map = new HashMap<String, String>();
                Element e = (Element) nl.item(i);
                // adding each child node to HashMap key => value
                map.put(KEY_ID, parser.getValue(e, KEY_ID));
                map.put(KEY_NAME, parser.getValue(e, KEY_NAME));
                map.put(KEY_COST, "Rs." + parser.getValue(e, KEY_COST));
                map.put(KEY_DESC, parser.getValue(e, KEY_DESC));

                // adding HashList to ArrayList
                menuItems.add(map);
            }

            // Adding menuItems to ListView
            ListAdapter adapter = new SimpleAdapter(this, menuItems,R.layout.list_item,
                      new String[] { KEY_NAME, KEY_DESC, KEY_COST }, 
                      new int[] { R.id.status_data_user, R.id.status_data_msg, R.id.status_data_date });

here are the errors:

10-23 21:33:55.379: W/dalvikvm(613): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
10-23 21:33:55.402: E/AndroidRuntime(613): FATAL EXCEPTION: main
10-23 21:33:55.402: E/AndroidRuntime(613): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.vlad.xml.parser.app/com.vlad.xml.parser.app.MainActivity}: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
10-23 21:33:55.402: E/AndroidRuntime(613):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
10-23 21:33:55.402: E/AndroidRuntime(613):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
10-23 21:33:55.402: E/AndroidRuntime(613):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
10-23 21:33:55.402: E/AndroidRuntime(613):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
10-23 21:33:55.402: E/AndroidRuntime(613):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-23 21:33:55.402: E/AndroidRuntime(613):  at android.os.Looper.loop(Looper.java:123)
10-23 21:33:55.402: E/AndroidRuntime(613):  at android.app.ActivityThread.main(ActivityThread.java:4627)
10-23 21:33:55.402: E/AndroidRuntime(613):  at java.lang.reflect.Method.invokeNative(Native Method)
10-23 21:33:55.402: E/AndroidRuntime(613):  at java.lang.reflect.Method.invoke(Method.java:521)
10-23 21:33:55.402: E/AndroidRuntime(613):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
10-23 21:33:55.402: E/AndroidRuntime(613):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
10-23 21:33:55.402: E/AndroidRuntime(613):  at dalvik.system.NativeStart.main(Native Method)
10-23 21:33:55.402: E/AndroidRuntime(613): Caused by: java.lang.RuntimeException: Your content must have a ListView whose id attribute is 'android.R.id.list'
10-23 21:33:55.402: E/AndroidRuntime(613):  at android.app.ListActivity.onContentChanged(ListActivity.java:245)
10-23 21:33:55.402: E/AndroidRuntime(613):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:201)
10-23 21:33:55.402: E/AndroidRuntime(613):  at android.app.Activity.setContentView(Activity.java:1647)
10-23 21:33:55.402: E/AndroidRuntime(613):  at com.vlad.xml.parser.app.MainActivity.onCreate(MainActivity.java:37)
10-23 21:33:55.402: E/AndroidRuntime(613):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-23 21:33:55.402: E/AndroidRuntime(613):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
10-23 21:33:55.402: E/AndroidRuntime(613):  ... 11 more
  • 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-13T09:25:01+00:00Added an answer on June 13, 2026 at 9:25 am

    I found the solution from this site: http://eureka.ykyuen.info/2010/01/03/android-simple-listview-using-simpleadapter/

    and this is what i found:

    public class MainActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        ListView lv= (ListView)findViewById(R.id.listview);
    
        // create the grid item mapping
        String[] from = new String[] {"rowid", "col_1", "col_2"};
        int[] to = new int[] { R.id.item1, R.id.item2, R.id.item3 };
    
    
        // prepare the list of all records
        List<HashMap<String, String>> fillMaps = new ArrayList<HashMap<String, String>>();
        for(int i = 0; i < 10; i++){
            HashMap<String, String> map = new HashMap<String, String>();
            map.put("rowid", "" + i);
            map.put("col_1", "col_1_item_" + i);
            map.put("col_2", "col_2_item_" + i);
            fillMaps.add(map);
        }
    
        // fill in the grid_item layout
        SimpleAdapter adapter = new SimpleAdapter(this, fillMaps, R.layout.grid_item, from, to);
        lv.setAdapter(adapter);
    }
    

    }

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

Sidebar

Related Questions

I have a program that gets a JSON from the server using getJSON and
I have a Java program that is supplied a directory name, gets a list
I have a program that reads from a file that grabs 4 bytes from
I have a table that gets rendered by Knockout <table data-bind=visible: program> <thead> <tr>
I have a program that gets input from the user via swing through a
I have a program that reads in lines from a file (with two lines)
I have a simple Python program that gets artwork from MP3 files. But when
hi i have a little program here that gets a directory from the command
I have an AJAX program which gets data from the website and posts the
I have a program that gets the FOV angle of the device's rear-facing camera,

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.