简体   繁体   中英

Adding a menu in Custom BottomSheetDialog Android

The is what i want to have

I have a BottomSheetDialog and i have inflated my custom layout on it. But when i try to add the menu to it. It doesn't appear.

Discord has the same thing with the menu appearing in the corner as you can see in the image above. How am i supposed to do it. Please help me out.

Here is my code

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

}

I don't think this is possible, nor is the Options Menu meant for this. This is from the documentation on menus :

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

I think the PopUpMenu would be more appropriate here:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM