ContextMenu从哪里获得布局?

时间:2015-09-30 23:03:21

标签: android android-layout menu

我正在关注官方的android教程指南,以便在长时间点击列表视图时创建上下文菜单。 http://developer.android.com/guide/topics/ui/menus.html#xml

一切正常,但我的上下文菜单有一个奇怪的边缘,标题的文本颜色设置为蓝色,这是我以前从未在我的应用程序中使用过的颜色。

我想知道上下文菜单在哪里获取信息以设置其边距和文本颜色?它当然不是上下文菜单的默认设置。

1 个答案:

答案 0 :(得分:0)

I think the layout of the context menu depends upon the android version you are using. If you want to customize the menu you should create a layout in the res->menu and then inflate it yourself.

Like this:

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

you can refer to the same doc for custom context menu.