Sunday, 23 October 2016

Menus in android

Menus are a typical UI part in numerous sorts of utilizations. To give a well known and steady client encounter, you ought to utilize the Menu APIs to present client activities and different choices in your exercises.
There are three types of Menus in android.

Menus in Android

1) Options menu :-

The Options menu (or) choices menu is the essential gathering of menu things for a movement. It's the place you ought to place activities that globally affect the application, for example, "Look", "Form email," and "Settings."

    Example :-
                       public boolean onCreateOptionsMenu(Menu menu) {
                       MenuInflater inflater=getMenuInflater();
                       return true;

2) Context menu :-

    A Context menu is a skimming menu that shows up when the client plays out a long-tap on a     
    component. It gives activities that influence the chose substance or setting outline.

   Example :-
                        public boolean onContextItemSelected(MenuItem item)
                        AdapterContextMenuInfo info = (AdapterContextMenuInfo)item.getMenuInfo();
                        Switch (item.getItemId())
                        return true;
                        return true;
                        return super.onContextItemSelected(item);

 Contextual action mode :-

  The Contextual action mode shows activity things that influence the chose content in a bar at the 
 highest point of the screen and permits the client to choose various things.

3) Popup menu :-

    A popup menu shows a rundown of things in a vertical rundown that is secured to the view that conjured the menu. It's useful for giving a flood of activities that identify with particular substance or to give choices to a second part of a summon. Activities in a popup menu ought not specifically influence the relating substance—that is the thing that relevant activities are for. Or maybe, the popup menu is for stretched out activities that identify with areas of substance in your action.

Example :-
               PopupMenu ppm = new PopupMenu(this,view);

No comments:

Post a Comment