hello guys here is the image of my context menu but i don't know how i can customize its view ??
i created context menu by 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");
}
but i wan't my menu to look like the one below ............. i wan't to know how i can change the color etc of the context menu??also the purple line that appear's,is that a nine patch image???
You can use AlertDialog
to implement any custom context menu. create custom style view by
AlertDialog.Builder.setCustomTitle(View customTitleView) & AlertDialog.Builder.setView(View view)
You can listen to the long press event, and popup this dialog.
I am confuse with your question little bit , correct me if i am wrong,
Case 1 : You just want to set Title as second image you pasted. For that you have to just setTitle()
like menu.setHeaderTitle("Select Option");
,
So, Whole code should be like this ,
@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");
}
Case 2: You are asking about some other Themes.In that case you should use other context menu theme.
Case 3 : You totally want to change UI , and want to make own UI. In that case you should have to create custom dialog and use as Context Menu.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With