When I use a simple array that i define in this class, it works fine, but when I call on this string array from my strings.xml, it never seems to work….Any suggestions? I’m trying to make a menu that lists all the chapter titles
What am I doing wrong???
I’m pretty new to java and android, so please dumb it down as much as possible….Thanks!
import android.app.ListActivity;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.ArrayAdapter;
public class ChapterMenu extends ListActivity{
Resources res= getResources();
String [] chapterArray = res.getStringArray(R.array.chapters);
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(ChapterMenu.this, android.R.layout.simple_list_item_1, chapterArray));
}
1 Answer