我制作了一个简单的列表,当单击 ListItem 时它会调用其他活动,但它对我不起作用。当我点击时,什么都没有出现。怎么了 ?这是代码:
String classes[]={"StartingPoint","Splash", "ex1","ex2"};
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, classes));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
String cheese = classes[position];
try
{
Class ourclass = Class.forName("com.alfred.splashscreenwithsound." + cheese);
Intent myintent = new Intent(this,ourclass);
startActivity(myintent);
}
catch(ClassNotFoundException e)
{
e.printStackTrace();
}
}
}