Customize context menu view in android?

Hi guys, here is an image of my context menu but I don’t know how I can customize its presentation

I created a context menu using this code

  @Override
    public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) 
    {//local=v;
                    super.onCreateContextMenu(menu, v, menuInfo);      
                   info = (AdapterContextMenuInfo) menuInfo;
                   menu.add(Menu.NONE, v.getId(), 0, "Play");
                   menu.add(Menu.NONE, v.getId(), 0, "Queue song");                  
                   menu.add(Menu.NONE, v.getId(), 0, "Edit tags");
                   menu.add(Menu.NONE, v.getId(), 0, "Set as ringtone");
                   menu.add(Menu.NONE, v.getId(), 0, "View details");
                   menu.add(Menu.NONE, v.getId(), 0, "Delete");

    }

enter image description here

but I don’t want my menu to look like the one shown below ............. I won’t know how I can change the color, etc. context menu? also the purple line that appears is that there are nine patch images ???

enter image description here

+4
source share
2 answers

You can use AlertDialogto implement any custom context menu. create your own style in style

AlertDialog.Builder.setCustomTitle(View customTitleView) & AlertDialog.Builder.setView(View view)

You can listen to a long press event and pop up in this dialog box.

+3
source

, , ,

1: Title , . setTitle() menu.setHeaderTitle("Select Option");, , ,

   @Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) 
{//local=v;
                super.onCreateContextMenu(menu, v, menuInfo);      
               info = (AdapterContextMenuInfo) menuInfo;
               menu.setHeaderTitle("Select Option"); 
               menu.add(Menu.NONE, v.getId(), 0, "Play");
               menu.add(Menu.NONE, v.getId(), 0, "Queue song");                  
               menu.add(Menu.NONE, v.getId(), 0, "Edit tags");
               menu.add(Menu.NONE, v.getId(), 0, "Set as ringtone");
               menu.add(Menu.NONE, v.getId(), 0, "View details");
               menu.add(Menu.NONE, v.getId(), 0, "Delete");

}

2:. . .

3: . .

+2

All Articles