Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Pop Up Menu Android

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 525
    Comment on it

    Pop up menu simply show Menu in a pop up window anchored to a View.

    It displays the pop up below the anchor view if it finds space otherwise above the anchor view.

    If we touch outside of it, then it will dismiss the pop up menu.

    First, we need to define menu xml file in menu folder.


    <?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="">
            <item android:id="@+id/add_info" android:title="Add Info" />
            <item android:id="@+id/delete" android:title="Delete"/>

    Then create Pop up in java


        PopupMenu popup = new PopupMenu(getActivity(), mMoreInfo);
    // mMoreInfo is a button, and I am doing all this on click of mMoreInfo
                //Inflating the Popup using xml file
                popup.getMenuInflater().inflate(, popup.getMenu());
                //registering popup with OnMenuItemClickListener
                popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
                    public boolean onMenuItemClick(MenuItem item) {
                        if (item.getTitle().equals("Add Info")) {
                          Toast.makeText(getActivity(), "Add Info.", Toast.LENGTH_LONG).show();
                        if (item.getTitle().equals("Delete")) {
                            //ParseObject cln = ParseObject.createWithoutData("User_Pitch", videoDetailsArrayList.get(position).getObjectId());
     Toast.makeText(getActivity(), "Delete.", Toast.LENGTH_LONG).show();
                        return true;
      ;//showing popup menu


 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: