8 Apr 2014

Arc Menu | Satellite Menu in android

Hello Friends, 

There is so many ways to display menu in android application, here i am sharing one of the nice way to display menu in android application.


OUTPUT SCREEN:



MainActivity.java

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.Toast;
import com.capricorn.ArcMenu;
import com.capricorn.RayMenu;


public class MainActivity extends Activity 
{
 private static final int[] ITEM_DRAWABLES = { R.drawable.composer_camera, R.drawable.composer_music,
  R.drawable.composer_place, R.drawable.composer_sleep, R.drawable.composer_thought, R.drawable.composer_with };

 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState)
 {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);

  ArcMenu arcMenu = (ArcMenu) findViewById(R.id.arc_menu);
  ArcMenu arcMenu2 = (ArcMenu) findViewById(R.id.arc_menu_2);

  initArcMenu(arcMenu, ITEM_DRAWABLES);
  initArcMenu(arcMenu2, ITEM_DRAWABLES);

  RayMenu rayMenu = (RayMenu) findViewById(R.id.ray_menu);
  final int itemCount = ITEM_DRAWABLES.length;
  for (int i = 0; i < itemCount; i++) 
  {
   ImageView item = new ImageView(this);
   item.setImageResource(ITEM_DRAWABLES[i]);

   final int position = i;
   rayMenu.addItem(item, new OnClickListener() 
   {

    @Override
    public void onClick(View v) 
    {
     Toast.makeText(MainActivity.this, "position:" + position, Toast.LENGTH_SHORT).show();
    }
   });// Add a menu item
  }
 }

 private void initArcMenu(ArcMenu menu, int[] itemDrawables) 
 {
  final int itemCount = itemDrawables.length;
  for (int i = 0; i < itemCount; i++) 
  {
   ImageView item = new ImageView(this);
   item.setImageResource(itemDrawables[i]);

   final int position = i;
   menu.addItem(item, new OnClickListener() 
   {
    @Override
    public void onClick(View v) 
    {
     Toast.makeText(MainActivity.this, "position:" + position, Toast.LENGTH_SHORT).show();
    }
   });
  }
 }
}
Download Full source code from here ArcMenu 
Download Full source code Satellite Menu from here SatelliteMenu
I will be happy if you will provide your feedback or follow this blog. Any suggestion and help will be appreciated.
Thank you :)

7 comments:

  1. I cannot make the arc menu to be appear on the bottom. i need menu to be fix it on the bottom

    ReplyDelete
    Replies
    1. Hello
      were you able to make the menu appear on the bottom ? I am facing the same problem !

      Delete
  2. Dear Hasmukh,

    This tut is awesome. I am trying to learn ARC MENU and it has helped me so much.

    However, I am facing difficulty at one place. I want the "+" icon on the EXACT "Bottom Left" side of the screen (As original PATH app), but I am unable to do it.

    Please help me regarding this.

    Thank you.

    Regards,
    Vivek Joshi
    vivekjoshi225@gmail.com
    7383524664

    ReplyDelete
  3. Thanks for the example it helped me a lot but i want the menu to be opened for the first time.

    ReplyDelete
  4. Excuse me. Can you tell me how to change the position of the red point. thx.

    ReplyDelete
  5. hi i want to display some of the items of ray Menu in next line. how can i do this.

    ReplyDelete
  6. satellitemenu (maven)dependency

    ReplyDelete