|
// first add these to classes : |
|
https://github.com/frogermcs/InstaMaterial/blob/master/app/src/main/java/io/github/froger/instamaterial/ui/view/FeedContextMenu.java |
|
https://github.com/frogermcs/InstaMaterial/blob/master/app/src/main/java/io/github/froger/instamaterial/ui/view/FeedContextMenuManager.java |
|
|
|
// Then add dependency ButterKnife : |
|
// butterknife |
|
compile 'com.jakewharton:butterknife:8.4.0' |
|
annotationProcessor 'com.jakewharton:butterknife-compiler:8.4.0' |
|
|
|
// add view_context_menu.xml the layout of the menu : |
|
<?xml version="1.0" encoding="utf-8"?> |
|
<merge xmlns:android="http://schemas.android.com/apk/res/android"> |
|
|
|
<Button |
|
android:id="@+id/btnUpdate" |
|
style="@style/ContextMenuButton" |
|
android:text="Update" /> |
|
|
|
<Button |
|
android:id="@+id/btnDelete" |
|
style="@style/ContextMenuButton" |
|
android:text="Delete" /> |
|
|
|
<Button |
|
android:id="@+id/btnBlock" |
|
style="@style/ContextMenuButton" |
|
android:text="Signaler" /> |
|
|
|
<View |
|
android:layout_width="match_parent" |
|
android:layout_height="1dp" |
|
android:background="#eeeeee" /> |
|
|
|
<Button |
|
android:id="@+id/btnCancel" |
|
style="@style/ContextMenuButton" |
|
android:text="CANCEL" /> |
|
|
|
</merge> |
|
|
|
// add this style to your style.xml : |
|
<style name="ContextMenuButton"> |
|
<item name="android:layout_width">match_parent</item> |
|
<item name="android:layout_height">wrap_content</item> |
|
<item name="android:background">@drawable/btn_context_menu</item> |
|
<item name="android:gravity">left|center_vertical</item> |
|
<item name="android:paddingLeft">20dp</item> |
|
<item name="android:paddingRight">20dp</item> |
|
<item name="android:textColor">@color/colorPrimary</item> |
|
<item name="android:textSize">14sp</item> |
|
</style> |
|
|
|
// add btn_context_menu.xml to drawable : |
|
https://github.com/frogermcs/InstaMaterial/blob/master/app/src/main/res/drawable/btn_context_menu.xml |
|
|
|
// add these colors to color.xml : |
|
<color name="btn_default_light_normal">#00000000</color> |
|
<color name="btn_default_light_pressed">#40ffffff</color> |
|
<color name="btn_send_normal">#02c754</color> |
|
<color name="btn_send_pressed">#006633</color> |
|
<color name="btn_default_shadow">#99000000</color> |
|
<color name="btn_context_menu_normal">#ffffff</color> |
|
<color name="btn_context_menu_pressed">#40000000</color> |
|
<color name="btn_context_menu_text_red">#ffff0000</color> |
|
|
|
// add the background image to your drawable : |
|
https://github.com/NachosIO/parentoo/blob/master/ParentooAndroid/app/src/main/res/drawable-hdpi/bg_container_shadow.9.png |
|
|
|
//finally inside your activity affect the menu to a image or button : |
|
options = (ImageView) view.findViewById(R.id.options); |
|
options.setOnClickListener(new View.OnClickListener() { |
|
@Override |
|
public void onClick(View v) { |
|
FeedContextMenuManager.getInstance().toggleContextMenuFromView(v, new FeedContextMenu.OnFeedContextMenuItemClickListener() { |
|
@Override |
|
public void onUpdateClick(String objectId) { |
|
Toast.makeText(getActivity(),"ottloub",Toast.LENGTH_SHORT).show(); |
|
FeedContextMenuManager.getInstance().hideContextMenu(); |
|
} |
|
|
|
@Override |
|
public void onDeleteClick(String objectId) { |
|
Toast.makeText(getActivity(),"esstalem",Toast.LENGTH_SHORT).show(); |
|
FeedContextMenuManager.getInstance().hideContextMenu(); |
|
} |
|
|
|
@Override |
|
public void onBlockClick(String objectId) { |
|
FeedContextMenuManager.getInstance().hideContextMenu(); |
|
} |
|
|
|
@Override |
|
public void onCancelClick(String objectId) { |
|
FeedContextMenuManager.getInstance().hideContextMenu(); |
|
} |
|
} , true); |
|
} |
|
}); |