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

The Archive Base Latest Questions

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

I am dynamically creating objects in the program and populating them from an array.xml.

  • 0

I am dynamically creating objects in the program and populating them from an array.xml.
In the array.xml I have a series of tools and values and I need to load these into the class values for each item.

Here is what I have in the class;

public class ToolImporter extends Application{

public static Tool[] tools;
private String[] aTool;
private int i;

public ToolImporter() {

    aTool = getResources().getStringArray(R.array.tools); //null pointer?

    // TODO Auto-generated constructor stub
}

and this is my array.xml;

    <array name="tools">
        <item name="SAW">
            <id>1</id>
            <image>R.drawable.image_saw100x60px</image>
            <boxX>100</boxX>
            <boxY>100</boxY>
            <worktopX>200</worktopX>
            <worktopY>200</worktopY>
        </item>
        <item name="SCREWDRIVER">
            <id>2</id>
            <image>R.drawable.image_screwdriver100x60px</image>
            <boxX>150</boxX>
            <boxY>100</boxY>
            <worktopX>250</worktopX>
            <worktopY>200</worktopY>
        </item>
        <item name="HAMMER">
            <id>3</id>
            <image>R.drawable.image_hammer100x60px</image>
            <boxX>200</boxX>
            <boxY>100</boxY>
            <worktopX>300</worktopX>
            <worktopY>200</worktopY>
        </item>
    </array>

However, it throws a null pointer on the “//null pointer?” line.
Can anyone offer advice on what i’m doing wrong to import it?

  • 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-15T23:36:56+00:00Added an answer on June 15, 2026 at 11:36 pm

    According to this post:

    You shouldn’t call getResources() unless onCreate() callback has been triggered.

    public class StackStackActivity extends Activity 
    {
    
        String[] myArray = getResources().getStringArray(R.array.glenns); // This returns null
    
        public StackStackActivity()
        {
    
            myArray = getResources().getStringArray(R.array.glenns); // This returns null also
        }
    
        @Override
        public void onCreate(Bundle savedInstanceState) 
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
            myArray = getResources().getStringArray(R.array.glenns); // Returns an array from resources
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm currently dynamically creating UIButton objects in my view. I have an NSMutableArray containing
I am working on creating some grails domain objects dynamically and then adding them
I'm creating objects dynamically and inserting them into an html table, the objects are
I need to dynamically create com objects from an activex dll and each of
Using mootools I have a 'builder' class that manufactures form objects, dynamically creating divs
I'm currently designing an app that calls for dynamically creating objects and then displaying
I'm dynamically creating textfields in as3, and formatting them with the TextFormat class. I'm
I am dynamically creating a RadGrid and adding GridTemplateColumns to it. Those columns have
I have about 10 different objects that get populated from user input. Instead of
I have 4 UITextFields that I'm dynamically creating, in the viewDidLoad, which works good.

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.