充气上下文菜单中SherlockListFragment [英] Inflate context menu in a SherlockListFragment

查看:101
本文介绍了充气上下文菜单中SherlockListFragment的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从XML在 SherlockListFragment 创建一个文本菜单。我知道(见例子)

How to create a Contextmenu from xml in a SherlockListFragment. i know (see in the examples)

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    menu.add("One");
    menu.add("Two");
    menu.add("Three");
    menu.add("Four");
}

这工作太为 SherlockListFragment ,但我想从菜单/ context_menu.xml膨胀

this work too for SherlockListFragment but i wanna inflate from a menu/context_menu.xml

推荐答案

过了一会儿,我找到了解决办法。

after a while i found the solution

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    getSherlockActivity().getMenuInflater().inflate(R.menu.context_menu, menu);
}

这篇关于充气上下文菜单中SherlockListFragment的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆