gpt4 book ai didi

java - 在 Custom BottomSheetDialog Android 中添加菜单

转载 作者:行者123 更新时间:2023-12-05 00:03:01 25 4
gpt4 key购买 nike

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);
}

}

最佳答案

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

"The options menu is the primary collection of menu items for anactivity. It's where you should place actions that have a globalimpact on the app, such as "Search," "Compose email," and "Settings."


我认为 PopUpMenu在这里会更合适:

"Rather, the popup menu is for extended actions that relate to regions of content in your activity."

关于java - 在 Custom BottomSheetDialog Android 中添加菜单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67740604/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com