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