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

  • Home
  • SEARCH
  • 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 598601
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:24:21+00:00 2026-05-13T16:24:21+00:00

I read a tutorial, and it uses SQLlite and SimpleCursorAdapter to fill the list

  • 0

I read a tutorial, and it uses SQLlite and “SimpleCursorAdapter” to fill the list with items.
This is the code the tutorial taught me.

private void fillData() {
        // Get all of the notes from the database and create the item list
        Cursor c = mDbHelper.fetchAllNotes();
        startManagingCursor(c);

        String[] from = new String[] { NotesDbAdapter.KEY_TITLE };
        int[] to = new int[] { R.id.text1 };

        // Now create an array adapter and set it to display using our row
        SimpleCursorAdapter notes =
            new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to);
        setListAdapter(notes);
    }

However…what if I want to fill it with XML data? Is it the same method? Can someone give me an example (in code)? thanks.

  • 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-13T16:24:22+00:00Added an answer on May 13, 2026 at 4:24 pm

    The example is using a CursorAdapter because a Cursor object is returned by the NotesDbAdapter (if i remember correctly ) fetchAllNotes method. I don’t know if there is a way to pass in raw XML to create a list but you can use name/value pairs in a HashMap to create a list using the SimplelistAdapter.

    You can parse your xml and or json and build a hash table with it and use that to populate a list. The following example doesn’t use xml, in fact it’s not dynamic at all, but it does demonstrate how to assemble a list at runtime. It’s taken from the onCreate method of an activity that extends ListActivity. The all uppercase values are static constant strings defined at the top of the class, and are used as the keys.

    // -- container for all of our list items
    List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
    
    // -- list item hash re-used
    Map<String, String> group;
    
    // -- create record
    group = new HashMap<String, String>();
    
    group.put( KEY_LABEL, getString( R.string.option_create ) );
    group.put( KEY_HELP,  getString( R.string.option_create_help ) );
    group.put( KEY_ACTION, ACTION_CREATE_RECORD );
    
    groupData.add(group);
    
    // -- geo locate
    group = new HashMap<String, String>();
    
    group.put( KEY_LABEL, getString(R.string.option_geo_locate ) );
    group.put( KEY_HELP, getString(R.string.option_geo_locate_help ) )
    group.put( KEY_ACTION, ACTION_GEO_LOCATE );
    
    groupData.add( group );
    
    // -- take photo
    group = new HashMap<String, String>();
    
    group.put( KEY_LABEL, getString( R.string.option_take_photo ) );
    group.put( KEY_HELP, getString(R.string.option_take_photo_help ) );
    group.put( KEY_ACTION, ACTION_TAKE_PHOTO );
    
    groupData.add( group );
    
    // -- create an adapter, takes care of binding hash objects in our list to actual row views
    SimpleAdapter adapter = new SimpleAdapter( this, groupData, android.R.layout.simple_list_item_2, 
                                                       new String[] { KEY_LABEL, KEY_HELP },
                                                       new int[]{ android.R.id.text1, android.R.id.text2 } );
    setListAdapter( adapter );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I read this tutorial about encryption in .NET it uses Rfc2898DeriveBytes to create a
I read the tutorial, https://developers.google.com/apps-script/articles/building-sites-app-part2 that uses spreadsheet service in Google sites. The code
So I read the tutorial from some web, and they did something like this.
To review regular expresions I read this tutorial . Anyways that tutorial mentions that
I am new to WP7. I followed this tutorial to read and write a
I'm new to silverlight and trying to read a silverlight tutorial that uses HitTest
In this font-size resizing tutorial: Quick and easy font resizing the author uses parseFloat
I have found this tutorial: http://dailyjs.com/2010/12/06/node-tutorial-5/ which uses a slightly different approach from build
I'm new to JSON and trying this tutorial: http://p-xr.com/android-tutorial-how-to-parse-read-json-data-into-a-android-listview/#comments I'm new to JSON, C
few days ago i read tutorial about GenericRepository and Unit Of Work patterns http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application

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.