我真的很難鏈接菜單。我想創建一個應用程序的應用程序的菜單,導致我打算在應用程序中打開的各種網站的鏈接。我創建了一個包含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();
}
}
目前這一切確實是打印使用敬酒方法的選擇,但我怎麼當我選擇了它,它切換到p.java類。在基本的我會採取名稱變量,並說如果名稱= p goto p.java,我已經GOOGLE了,雖然我得到的答案的一部分,我無法弄清楚如何實現它。
很多感謝提前。
嗨,Carl,感謝您的回覆,對不起,我是一個noob,也許我在走路之前就跑步了,但是我應該在哪裏放置代碼,我是否刪除了其他班級,並讓其他菜單位於同一區域類或我在哪裏可以找到一個這樣的例子,所以我可以看到這是如何工作的 – JonniBravo 2010-09-20 08:51:40