在android
中设置新菜单时,下面的块会引发错误@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
String ncall = Classes[position];
try {
Class ourClass=Class.forName("com.example.newtrynow.", + ncall );
\\above line shows error, why is "+" not supported its just appending the rest of string
Intent ourIntent=new Intent(Menu.this, ourClass);
startActivity(ourIntent);
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
答案 0 :(得分:0)
从以下行中删除逗号
Class ourClass=Class.forName("com.example.newtrynow.", + ncall );
应该是这样的
Class ourClass=Class.forName("com.example.newtrynow." + ncall );