9

I've been looking for something like Pinterest menu whenever item in GridView is pressed. I know it's too broad question. But little strike on question will provide a correct way to achieve these.

Que:

How one can implement customise context menu like Contacts+ or Pinterest Context menu on GridView item?

Pinterest Context Menu Contacts+ Context Menu

Tried:

ArcMenu : But they are replacement of Slider Menu or Pop up Menu for overall Application. I want menu which can be created onFly for GridView Item.

Satellite Menu : Same as ArcMenu, replacement of Slider Menu or Pop up Menu for overall Application.

Please enlighten me to achieve behaviour like these.

Vikalp Patel
  • 10,669
  • 6
  • 61
  • 96

4 Answers4

1

I think instead of Context Menu you can use PopupWindow for your requirement.

 //Custom popup view
View view= layoutInflater.inflate(R.layout.popupview, null);  
PopupWindow popupWindow = new PopupWindow(
               view, 
               LayoutParams.WRAP_CONTENT,  
                     LayoutParams.WRAP_CONTENT);

//Display popup window on clicking anything
//Displays pop up window near button with offsets 10 and -10
popupWindow.showAsDropDown(button, 10, -10);

For more info

http://developer.android.com/reference/android/widget/PopupWindow.html

http://android-er.blogspot.in/2012/03/example-of-using-popupwindow.html

Abhishek V
  • 12,488
  • 6
  • 51
  • 63
  • I can surely prefer `PopupWindow()`but has own limitation. One need to dismiss it manually(Dismiss through programmatically) also lot of Window Leakage error throws up due to `PopUpWindow()` + Rendering `PopupWindow()` at specific location or as drop down which is not useful in tweaking effective UIx. – Vikalp Patel May 19 '14 at 10:42
0

Use quick action 3D view. It is the menu which is used in twitter application.
For source: https://github.com/lorensiuswlt/NewQuickAction3D

Chandru
  • 5,954
  • 11
  • 45
  • 85
0

I'm using a modified version of ArcMenu (just small and mainly visual modifications) for something similar. And it's perfectly adaptable to gridview (i'm using it with StaggeredGridView onitemclick).

You only have to define it in the xml inside the gridview item with Visibility:gone and then in your gridview adapter or in the activity set it to visible when the item is touched or clicked...

don't know why you say it's for overall app, it can be used as an item element also.

Hugo
  • 1,662
  • 18
  • 35
-1

You can check out this library which I created:

https://github.com/reyanshmishra/PinMenu

You can clone it and import it as a module to your app and do something like this:

In your XML layout:

<?xml version="1.0" encoding="utf-8"?>
<com.reyanshmishra.pinmenu.PinMenuHolder xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:pin_holder_draw_over_view="true"
    app:pin_holder_overlay_color="#90ffffff">



    <com.reyanshmishra.pinmenu.PinMenu
        android:id="@+id/one"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:elevation="5dp"
        android:padding="5dp"
        android:scaleType="centerInside"
        android:src="@drawable/ic_close_black_24dp"
        app:pin_background_color="@color/white"
        app:pin_name="Cancel"
        app:pin_selected_color="#BD081C" />



    <com.reyanshmishra.pinmenu.PinMenu
        android:id="@+id/three"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:elevation="5dp"
        android:padding="5dp"
        android:scaleType="centerInside"
        android:src="@drawable/share_variant"
        app:pin_background_color="@color/white"
        app:pin_name="Share"
        app:pin_selected_color="#BD081C" />


    <com.reyanshmishra.pinmenu.PinMenu
        android:id="@+id/four"
        android:layout_width="48dp"
        android:layout_height="48dp"
        android:elevation="5dp"
        android:padding="5dp"
        android:scaleType="centerInside"
        android:src="@drawable/dots_horizontal"
        app:pin_background_color="@color/white"
        app:pin_name="More"
        app:pin_selected_color="#BD081C" />


</com.reyanshmishra.pinmenu.PinMenuHolder>

Now in Java:

PinDialog mPinDialog = new PinDialog(this);
        mPinDialog.setContentView(R.layout.layout_pin_menu);
           mPinDialog.setPinSelectListener(new PinSelectListener() {
                    @Override
                    public void pinSelected(PinMenu pinMenu) {
                        Toast.makeText(mContext, "" + pinMenu.getPinName(), Toast.LENGTH_SHORT).show();
                    }
                });

        mPinDialog.addToRecyclerView(mRecyclerView);

It's still under development so it just supports recyclerview. For depth of the implementation, you can just skim through the classes of the library. I don't think I can put all the code here.

The result it something like this:

enter image description here

Jamal
  • 763
  • 7
  • 22
  • 32
Reyansh Mishra
  • 1,879
  • 1
  • 14
  • 26