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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:36:36+00:00 2026-06-15T12:36:36+00:00

I know how to create a simple Array in xml like this <resources> <string-array

  • 0

I know how to create a simple Array in xml like this

<resources>
    <string-array name="countries_array">
        <item>Afghanistan</item>
        <item>Albania</item>
        <item>Algeria</item>
        <item>American Samoa</item>
        <item>Andorra</item>
        <item>Angola</item>
        <item>Anguilla</item>
        <item>Antarctica</item>
    </string-array>
</resources>

And then I initialize it like this in code

ArrayAdapter<String> adapter = 
        new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, countries_array);
textView.setAdapter(adapter);

But I want to store more items than just a string, so I need a way to store an arraylist rather than a simple array.

Like below

<resources>
<Share>
    <name>Apple</name>
    <currentRate>5.69</currentRate>
    <changeToday>-0.11</changeToday>
    <changeTodayPercent>-0.02</changeTodayPercent>
    <timeUpdated>2012,12,06,18,00,00</timeUpdated>
<Share>
<Share>
    <name>Microsoft</name>
    <currentRate>5.88</currentRate>
    <changeToday>0.19</changeToday>
    <changeTodayPercent>+0.09</changeTodayPercent>
    <timeUpdated>2012,12,06,18,00,00</timeUpdated>
<share>
...
</resources>

I already have a class called Share.java with following variables that need to be set via setMethods

public class ShareHolding {

private String name;
private double currentRate;
private double changeToday;
private double changeTodayPercent;
private GregorianCalendar timeUpdated;
}

and add them to an arraylist

ArrayList<Share> allShares = new ArrayList<Share>();

allShares.getShare(0).setName("I want to access my xml file here and add the first shares name here");
  • 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-15T12:36:37+00:00Added an answer on June 15, 2026 at 12:36 pm

    As far as I know, you won’t be able to mismatch data types using the resource file. The resource only supports one-way datatypes. e.g Array of string, array of integers, etc.

    The best solution that would work is to make the Share xml into it’s own file and parse is into your shared object. The android developer has some example of the built in xml parser

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

Sidebar

Related Questions

I know how to create simple object and add dynamically properties to it. object
I'm trying to create a pretty simple WPF interface, and from what I know
I'd like to know if there is a simple (or already created) way of
I'd like to create a very simple android activity that takes a file path
Watch out, learning sql newbie. I would like to create 2 simple tables. products:
I would like to create a new List<Object> from a simple List<Object> only for
Hi I have following simple xml object: [ad] => Array ( [0] => SimpleXMLElement
I'm just getting to know AppleScriptObj-C and trying to create a simple application that
Please help! I don't know if maybe this is too simple but I can't
Does anybody know of a tutorial or sample code on how to create a

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.