android - menu gui difficulty
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<开发者_StackOverflow;String>(ChapterMenu.this, android.R.layout.simple_list_item_1, chapterArray));
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
Resources res= getResources();
String [] chapterArray = res.getStringArray(R.array.chapters);
setListAdapter(new ArrayAdapter<String>(ChapterMenu.this, android.R.layout.simple_list_item_1, chapterArray));
}
精彩评论