我正在爲選項卡組使用活動組。活動組中的Contextmenu
其中一個子選項卡組中的Activity活動包含一個Contextmenu。但是當我點擊菜單項時,在所選的上下文菜單項下編寫的代碼沒有運行。
the code which i was written in tabgroup Activity is given below
@Override
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo) {
// TODO Auto-generated method stub
super.onCreateContextMenu(menu, v, menuInfo);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
// TODO Auto-generated method stub
return getLocalActivityManager().getCurrentActivity().onContextItemSelected(item);
}
,我寫在孩子Achtivity的代碼如下
public void onCreateContextMenu(ContextMenu menu, View v,
ContextMenuInfo menuInfo)
{
super.onCreateContextMenu(menu, v, menuInfo);
if(v.getId()==R.id.appointment_listview1)
{
AdapterView.AdapterContextMenuInfo info =
(AdapterView.AdapterContextMenuInfo)menuInfo;
appointmnt_row item = (appointmnt_row)appListView.getItemAtPosition(info.position);
menu.setHeaderTitle(dateString);
menu.add(0, item.getId(), 0, "Delete");
}
}
@Override
public boolean onContextItemSelected(MenuItem item) {
if(item.getTitle()=="Delete")
{Log.e("delete",""+item1.getId());
} return true;}
請給幫助我
顯示onContextItemSelected方法 – Yahor10
感謝您的互動。我認爲主要的問題是我使用的活動組,所以在兒童活動中實施上下文菜單是問題 – Vikky
你有沒有嘗試? onContextItemSelected中的getContextItemSelected(item)中的getLocalActivityManager()。getCurrentActivity()。看到這個問題http://stackoverflow.com/questions/3157406/android-activitygroup-menu-problem – Yahor10