我真的很難將菜單鏈接在一起。我想要創建的應用程序是一組菜單,這些菜單會導致我打算在應用程序中打開的各個網站的鏈接。我創建了一個包含8個選項的列表活動菜單,並且我有八個類別,並提供了更多選項。我的問題是如何將菜單鏈接在一起。我問這個問題,有人說我應該映射。下面是代碼:將菜單鏈接在一起
public class MyList extends ListActivity {
private static final String Cp = null;
private static final String Pp = null;
private static final String L2 = null;
private static final String L1 = null;
/** Called when the activity is first created. */
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Create an array of Strings, that will be put to our ListActivity
String[] names = new String[] { "Pp", "Cp", "L1", "L2", "Bt", "Se", "As", "Travel"};
// Create an ArrayAdapter, that will actually make the Strings above
// appear in the ListView
this.setListAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_list_item_checked, names));
}
{Map<String, Runner> runners = new HashMap<String, Runner>();
runners.put("Pp", (Runner) new Pp());
runners.put("Cp", (Runner) new Cp());
runners.put("L1", (Runner) new L1());
runners.put("L2", (Runner) new L2());
public void onListItemClick(runners.get(getListView()).L2();
runners.get(getListView()).L1();
runners.get(getListView()).Pp();
runners.get(getListView()).Cp(); {
我有安裝一類叫做流道和每個選項像這樣中添加的下一個菜單:
公共接口亞軍{
void L2();
void L1();
void Pp();
void Cp();
}
目前,我得到一個錯誤在這一行public void onListItemClick(runners.get(getListView())。League2(); void是變量onListItemClick的無效類型,我是否正確地做了這件事,我是否錯過了某些東西,這是我應該如何使用此方法??