0

I've noticed some programs use a popup toolbar for context menus instead of actual context menus, like in Sense (see image:)

enter image description here

How would I go about implementing something like that?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Elad Avron
  • 1,411
  • 1
  • 18
  • 28
  • Where you able to achieve this? Because I am working on the same thing, and having problems with positioning the popup box above the selection . – Jakob Harteg Jun 12 '14 at 07:41

2 Answers2

1

It's called a Quick Actions Popup, you have to create it yourself.

Refer this LINK.

Sample code snippet::

//Add action item
ActionItem addAction = new ActionItem();
addAction.setTitle("Add");
addAction.setIcon(getResources().getDrawable(R.drawable.ic_add));

//Accept action item
ActionItem accAction = new ActionItem();

accAction.setTitle("Accept");
accAction.setIcon(getResources().getDrawable(R.drawable.ic_accept));

//Upload action item
ActionItem upAction = new ActionItem();
upAction.setTitle("Upload");
upAction.setIcon(getResources().getDrawable(R.drawable.ic_up));

Create quickaction instance and setup listener

final QuickAction mQuickAction  = new QuickAction(this);

mQuickAction.addActionItem(addAction);
mQuickAction.addActionItem(accAction);
mQuickAction.addActionItem(upAction);

//setup the action item click listener
mQuickAction.setOnActionItemClickListener(new QuickAction.OnActionItemClickListener() {
    @Override
        public void onItemClick(int pos) {
        if (pos == 0) { //Add item selected
           Toast.makeText(Example1Activity.this, "Add item selected", Toast.LENGTH_SHORT).show();
        } else if (pos == 1) { //Accept item selected
           Toast.makeText(Example1Activity.this, "Accept item selected", Toast.LENGTH_SHORT).show();
        } else if (pos == 2) { //Upload item selected
           Toast.makeText(Example1Activity.this, "Upload items selected", Toast.LENGTH_SHORT).show();
        }
    }
});
Shankar Agarwal
  • 34,573
  • 7
  • 66
  • 64
1

these links correspond to exactly your needs, by the way this popup tool is called QuickAction:

QuickAction

QuickAction Dialog

Green Droid QuickAction

QuickActionBar and GridAction

Hope this will help you

K_Anas
  • 31,226
  • 9
  • 68
  • 81