Home > Android, Android how to, Menu > Adding icon to the menu item in Android

Adding icon to the menu item in Android


We moved. Please visit this link for this post.

 

 

 

There is a good practice to add icons to the menu items.

I am going to show code snippet which add icon to the menu item:

@Override
public boolean onCreateOptionsMenu(Menu menu) {
   menu.add(0, ADD_MENU_ITEM, 0, "Add").setIcon(android.R.drawable.ic_menu_add);
   return super.onCreateOptionsMenu(menu);
}

This code adds icon add to the menu item ADD_MENU_ITEM.

As you see this is simple operation.

Advertisements
Categories: Android, Android how to, Menu
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: