第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

onCreateonCreateContextMenu的其它參數(shù)的作用

@Override
public?void?onCreateContextMenu(ContextMenu?menu,?View?view,?ContextMenu.ContextMenuInfo?menuInfo)?{
????//設置Menu顯示內容
????menu.setHeaderTitle("文件操作");
????menu.setHeaderIcon(R.mipmap.ic_launcher);
????//通過讀取xml文件來設置
????this.getMenuInflater().inflate(R.menu.menu_context,menu);

????super.onCreateContextMenu(menu,?v,?menuInfo);
}

如上,onCreateContextMenu,除了menu,還有view
和menuInfo兩個參數(shù),它們怎么使用,或者它們的功能是什么?

正在回答

1 回答

menuInfo:

API文檔的解釋是:

Additional information regarding the creation of the context menu. ?For example, ?AdapterViews use this to pass the exact item position within the adapter that initiated the context menu.

我的理解是:ListView、GridView等AdapterView利用這個參數(shù)傳遞了被點擊item的具體position或id等信息。

用處:獲取長按項的值,作為上下文菜單的標題。例如:

int position = ((AdapterContextMenuInfo)menuInfo).position;??
menu.setHeaderTitle(mDatas.get(position).title);

view:注冊該上下文的view。例如:

this.registerForContextMenu(mListView);

則此處view即為mListView。

希望我的解釋對你有用~


0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消
Android攻城獅的第二門課(第2季)
  • 參與學習       62384    人
  • 解答問題       215    個

本課程講帶你熟悉Android開發(fā)中常用的調試方式,菜單、調試程序

進入課程

onCreateonCreateContextMenu的其它參數(shù)的作用

我要回答 關注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號