这是我的代码,我在这一行遇到错误:
String[] opt = getResources().getStringArray(R.array.MainActivity);
所以,请检查我的代码并告诉我如何解决该行中的错误
public class MainActivity extends ListActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
try {
String[] opt = getResources().getStringArray(R.array.MainActivity);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ListView lv = getListView();
ListAdapter la = new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_1, opt);
lv.setAdapter(la);
lv.setTextFilterEnabled(true);
lv.setChoiceMode(ListView.CHOICE_MODE_SINGLE);
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
switch (position) {
case 0:
Intent firstIntent = new Intent(MainActivity.this,
After1.class);
startActivity(firstIntent);
break;
case 1:
Intent secondIntent = new Intent(MainActivity.this,
After2.class);
startActivity(secondIntent);
break;
default:
break;
}
}