0
它有一个'class'以黄色下划线,并表示它的警告说'Class是一个原始类型。泛型类型参考应参数化'android开发eclipse(列表活动)
Class ourClass = Class.forName("com.thenewboston.jack." + cheese);
我试过所有的快速修复和每一件事情。我不知道该怎么办。任何人都可以帮助并告诉我该怎么办?
这里是代码的其余部分,并且其中所述代码被放置:
package com.thenewboston.jack;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
public class Menu extends ListActivity{
String classes[] = {"Startingpoint", "Example1", "Example2", "Example3"
, "Example4", "Example5", "Example6", "Example7", "Example7", "Example7"};
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setListAdapter(new ArrayAdapter<String>(Menu.this, android.R.layout.simple_expandable_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.thenewboston.jack." + cheese);
Intent ourIntent = new Intent(Menu.this, ourClass);
startActivity(ourIntent);
}catch(ClassNotFoundException e){
e.printStackTrace();
}
}
}
这不会摆脱警告类 ourClass = Class.forName(“com.thenewboston.jack。”+ cheese);然而,这是@SuppressWarnings(“rawtypes”)\t \t \t Class ourClass = Class.forName(“com.thenewboston.jack。”+ cheese);谢谢你的帮助,你能告诉我为什么另一个人不工作? –
2011-12-31 21:29:09