【发布时间】:2010-09-19 16:24:09
【问题描述】:
我真的很难将菜单链接在一起。我要创建的应用程序 os 是一组菜单,这些菜单指向我计划在应用程序中打开的各种站点的 url 链接。我创建了一个包含 8 个选项的列表活动菜单,并且我有八个带有更多选项的类。我的问题是如何将菜单链接在一起。
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
// Create an array of Strings, that will be put to our ListActivity
String[] names = new String[] { "P", "Ch", "Le", "Le", "B", "Sk", "Awa", "Tra"};
// 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));
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
super.onListItemClick(l, v, position, id);
// Get the item that was clicked
Object o = this.getListAdapter().getItem(position);
String keyword = o.toString();
Toast.makeText(this, "You selected: " + keyword, Toast.LENGTH_LONG)
.show();
}
}
目前所做的只是使用 toast 方法打印选择,但是当我选择它时如何让它切换到 p.java 类。基本上,我会使用 names 变量并说 if names = p goto p.java,我已经用谷歌搜索了,虽然我得到了部分答案,但我不知道如何实现它。
提前致谢。
【问题讨论】: