Android UI pattern implementations

Most Android users may have recognized more and more common UI elements in Android applications these days. Widgets like ActionBar and QuickActions are a great approach to standardize the way Android applications are used. Google posted some design proposals and took the Twitter for Android app as a great example for Android design patterns. A more precise definition for these and more patterns can be found at androidpatterns.com.
Of course, I immediately needed to have some of these in my own applications. So I started looking for Google’s implementation examples or developer documentation – nothing! Not even a code snippet. Fortunately, I was not the only one with that problem. I found some pretty good implementations for ActionBar and QuickActions, but I was looking for a more “integrated” solution, so I continued my research. Hours of googling later, I found a video from a talk at Google I/O 2010, which pointed me at the Google I/O app, which seems to be a good reference. But I wanted a library, not an example implementation and so I kept on searching. Finally, I found this awesome project, which perfectly fits my needs: Greendroid!

Greendroid

… is the most complete library for android UI patterns I found by now. Just load the Greendroid project into Eclipse, add it as a library to your project and you’re ready to go! To give you an example, creating an ActionBar and filling it with items is as easy as this:

1. Put this into your XML layout:

<greendroid.widget.ActionBar
 	android:id="@+id/MyActionBar" 
	android:layout_height="@dimen/gd_action_bar_height"
	android:layout_width="fill_parent" />

2. Fill your ActionBar with items and a title:

@Override
	public void fillActionBar(final ActionBar mActionBar) {
		mActionBar.addItem(Type.Compose);
		mActionBar.addItem(Type.Refresh);
		mActionBar.addItem(Type.Locate);
		mActionBar.setTitle("My ActionBar");
		mActionBar.setOnActionBarListener(new OnActionBarListener() {

			@Override
			public void onActionBarItemClicked(int position) {
				switch(position) {
				case 0:
					// Compose action
					break;
				case 1:
					// Refresh action
					LoaderActionBarItem item = (LoaderActionBarItem) mActionBar.getItem(position);
					// Turn the item into a progress indicator
					item.setLoading(true);
					break;
				case 2:
					// Map action
					break;
 				default:
 					// Action for home button
					break;
 				}
 			}
	 });

I recommend you to take a look at their example application (also included in the repository) to see what else you can do with Greendroid. There isn’t really a documentation, but the example application is pretty much everything you need to understand how Greendroid should be used.

I hope we’ll see more applications use the UI patterns in the future to give the Android application landscape a more consistent look.
Have fun!