我真的很难将菜单链接在一起。我想要创建的应用程序是一组菜单,这些菜单会导致我打算在应用程序中打开的各个网站的链接。我创建了一个包含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的无效类型,我是否正确地做了这件事,我是否错过了某些东西,这是我应该如何使用此方法??