QuickActionView in Android

While I was searching for an custom implementation of the QuickContactBadge for Android, I went into this interesting post ( Lorenz’s Blog ), which had a custom widget called QuickAction.
While it’s a very nice widget, it didn’t fit my needs because I had the necessity of create different action layouts ( horizontal, vertical, grid.. ), so I made a very quick modification to the above code and I ended with this implementation.
Basically I removed from the original Class the ActionItem list and set a BaseAdapter as content source. In this way it’s more simple and easy to add more and different views to the widget.
Moreover I added the support for columns ( both fixed and automatic ).
Here you can see a snippet code of the QuickActionView creation:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public void onButtonClick( View v ) {
   
   // create the quick action view, passing the view anchor
   QuickActionView qa = QuickActionView.Builder( v );
   
   // set the adapter
   qa.setAdapter( new CustomAdapter( this ) );
     
   // set the number of columns ( setting -1 for auto )
   qa.setNumColumns( (int) (2 + (Math.random() * 10)) );
   qa.setOnClickListener( new DialogInterface.OnClickListener() {

      @Override
      public void onClick( DialogInterface dialog, int which ) {
         dialog.dismiss();
         Toast.makeText( getBaseContext(), "Selected item: " + which, Toast.LENGTH_SHORT ).show();
      }
   } );
     
   // finally show the view
   qa.show();
}

Here some Screenshots:

And here you can find the source code: source code

Lead Android developer at Aviary and New Yorker since 2011. Mixed marketing and artistic background with more than 10 years of experience with Flash actionscript and python before switching to android development.
  • shubham patni

    Hi friend…thanks to u and lorenz for sharing such concept.
    please give me some guidance to make circular Action Menu.

    thanks

  • http://twitter.com/lorensiuswlt Lorensius Londa

    Very nice modification, keep up the good work…;)

  • http://www.facebook.com/kansm Kanis Kan

    thanks.. good article..

  • http://twitter.com/mich_kan michael kan

    thank you :)

  • http://eazyigz.wordpress.com Igor Ganapolsky

    Thanks. It is helpful to get started. But the code is way too convoluted, especially with the randomness of creating action items. Most folks are looking for a menu dialog with a concrete set of items, not randomizing every time.

  • Silvan

    Very good article, I really like you posts. One question, I’m trying to combine two of your projects, The ImageView Zoom and Scroll and this QuicActionView. I’m trying to trigger the QuickAction from the onSingleTapConfirmed item, the problem is that I don’t have anchor View from there. Do you have any idea how to combine this, I have the X and Y coordinates.

    Thanx in advance!

  • Ehsan Tavakoli

    In The Name of Allah
    hi,
    How to change this design to new one that have 5 icons and its layout would be like down screen menu of android (3 icons on top and 2 ones on down).

    Thank you …

  • parag

    Nice Tutorial
    Now I want to Add Listview in QuickAction .
    How can i do this?

  • sash

    hie nice article… thank you for the changes done..but i just wanted concrete set of items in the menu…say 2 icons in the first row and 2 in the second row….could you please guide on how can we do that,… :) :)

  • Aniket

    It is a good artical no doubt. But It is only showing Quick action view at the top or bottom. Can you provide for quick action view on left and right side of button.

  • ankasarentcar

    good