Thursday, November 24, 2011

Android Quick Action Bar

Android  Quick Action Bar

Quick Actions are basically actions/functions in a popup bar that are triggered by specific visual elements/buttons/items on the screen. Quick Actions are used to display contextual actions typically used in list views but not limited to it. You can imagine a phone-book or contact list on the phone. Now, there are certain set of actions that will be common to all contacts in the views like; make a call, send message, edit contact or may be even transfer files by  Email, Bluetooth etc. Basically these functions that are common to items in a context can be put in the Quick Action bar. This way the screen is uncluttered and simple and more importantly we needn’t sacrifice on the actions needed.


DOWNLOAD SOURCE CODE

Screen Shot :



Create Actionable Items:
The below code snippet is used to create an actionable item i.e. the actions you would want to place in the quick action bar. Creating an actionable item involves specifying the title, setting an icon that represents the item which will help you relate to the action, and finally set a Listener for the action. The term itself is self-explanatory. Yes, it is used to determine the action to be performed when clicked or pressed. As far as the icon /image goes, it can be easily set by referring to it from the resources as is the case with any external resource set in android which you would aware of, I am most certain.

final QuickActionIcons edit = new QuickActionIcons();;
 edit.setTitle("Edit");
 edit.setIcon(getResources().getDrawable(R.drawable.edit));
 edit.setOnClickListener(new OnClickListener()
 {
 public void onClick(View v)
 {
// add u r action
 }

 });]

Create Quick Action Dialog:

This part is even simpler. Like in this example, when an item in the list view is clicked / pressed, a new quick action bar/dialog is created. Then all the actionable items that you have created in the previous step are appended one by one to the quick action bar. After this you simply have to specify the animation style i.e. how do you want the dialog to be displayed on screen.

resultPane.setOnItemClickListener(new OnItemClickListener()
    {
    public void onItemClick(AdapterView<?> parent, View view, int position, long id)
    {
      QuickActionBar qab = new QuickActionBar(view);

      qab.addItem(edit);
      qab.addItem(call);
      qab.addItem(send_data);
      qab.setAnimationStyle(QuickActionBar.GROW_FROM_LEFT);

      qab.show();
    }
    });








7 comments:

  1. hai,vijay i didnt got that source code,if u free just my mail id.... vjj565@gmail.com... great idea... superb....

    ReplyDelete
  2. download link takes to survey webpage.

    ReplyDelete
  3. Good blog but please remove that download link put in some others,its very irritating

    ReplyDelete
  4. Hello

    I uploaded different server .. Now i hope you can able to download

    ReplyDelete
  5. hey upload mp3 player's code

    ReplyDelete
  6. http://androidroadies.blogspot.in/ also see best tutorial...

    ReplyDelete

Check out this may be help you

Related Posts Plugin for WordPress, Blogger...