【问题标题】:Adding a menu in Custom BottomSheetDialog Android在 Custom BottomSheetDialog Android 中添加菜单
【发布时间】:2021-05-28 14:18:01
【问题描述】:

The is what i want to have

我有一个 BottomSheetDialog,并且我已经在其上扩展了我的自定义布局。但是当我尝试将菜单添加到它时。它没有出现。

Discord 与出现在角落的菜单具有相同的功能,如上图所示。我该怎么做。请帮帮我。

这是我的代码

//This is my ViewProfile BottomSheetDialog

public class ViewProfileFragment extends BottomSheetDialogFragment {

@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        CreateView = inflater.inflate(R.layout.fragment_view_profile, container, true);

        return CreateView;

    }

@Override
    public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
        super.onCreateOptionsMenu(menu, inflater);
        inflater.inflate(R.menu.view_profile_menu, menu);
    }

}

【问题讨论】:

    标签: java android modal-dialog android-bottomsheetdialog bottomsheetdialogfragment


    【解决方案1】:

    我认为这是不可能的,选项菜单也不是为此而生的。这是来自documentation on menus

    “选项菜单是菜单项的主要集合 活动。这是您应该放置具有全局性的操作的地方 对应用的影响,例如“搜索”、“撰写电子邮件”和“设置”。

    我认为PopUpMenu 在这里更合适:

    “相反,弹出菜单用于与您的活动中的内容区域相关的扩展操作。”

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多