Android上下文菜單生成函數onCreateContextMenu參數含義

public void onCreateContextMenu(ContextMenu menu, View v,ContextMenuInfo menuInfo)

其中參數含義如下:

menu:準備創建的菜單

v:觸發彈出菜單的組件。以ListView爲例,如果ListView的每個Item爲一個佈局文件xml,則v代表該佈局文件生成的View,使用v可直接獲取該佈局文件中的相應的組件

menuInfo:該對象提供當前選中項item的信息。例如以此可獲取選中的item的id:

AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();  int selItemId=info.position
 
發佈了17 篇原創文章 · 獲贊 2 · 訪問量 3萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章