I'm just trying to display a list from an array that I have in my arrays.xml . When I try to run it in the emulator, I get a power message.
If I define an array in a java file
String[] testArray = new String[] {"one","two","three","etc"};
it works but when i use
String[] testArray = getResources().getStringArray(R.array.testArray);
he does not work.
Here is my java file:
package com.xtensivearts.episode.seven; import android.app.ListActivity; import android.os.Bundle; import android.widget.ArrayAdapter; public class Episode7 extends ListActivity { String[] testArray = getResources().getStringArray(R.array.testArray); @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);
Here is my arrays.xml file
<?xml version="1.0" encoding="utf-8"?> <resources> <array name="testArray"> <item>first</item> <item>second</item> <item>third</item> <item>fourth</item> <item>fifth</item> </array> </resources>
java android arrays
Soren Mar 16 '10 at 11:45 2010-03-16 11:45
source share