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:

[cc lang=”java”]
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();
}
[/cc]

Here some Screenshots:

And here you can find the source code: source code