Android菜单标题元素

时间:2016-04-18 19:23:42

标签: android android-layout android-spinner android-xml android-menu

在Android xml中,我知道菜单可以定义为:

CreateMap<SuperModel, SuperEntity>()
    .ForMember(dest => dest.Entity1, opt => opt.MapFrom(src => src.Model1))
    .ForMember(dest => dest.Entity2, opt => opt.MapFrom(src => src.Model2))
            .AfterMap((m, e) => e.Entity2.NickName = m.Model1.NickName);

它包含<menu /> 个,其中包含drawable,titles和ID。有时,这些项目包含子<item />标记。如何在整个<menu />元素中添加标题,例如在此图片中?

Android Menu XML with title

此外,菜单的标题如何在此图片中着色?谢谢!

1 个答案:

答案 0 :(得分:0)

也许你可以试试ListPopupWindow。我想这可行。

您必须实现具有您描述的行为的自定义适配器。 然后:

YourCustomAdapter yca = new YourCustomAdapter();

ListPopupWindow popupWindow = new ListPopupWindow(context);
popupWindow.setAdapter(new YourCustomAdapter());
popupWindow.setWidth(300);      // Prefer using DPI scaling.
popupWindow.setAnchorView(yourView);

提示:如果可以,请使用ListPopupWindow的支持库版本。