31

What is the best way to implement action bar like twitter sample UI Pattern.

Twitter for Android: A closer look at Android’s evolving UI patterns Pattern 4: Action Bar http://android-developers.blogspot.com/2010/05/twitter-for-android-closer-look-at.html

CACuzcatlan
  • 5,407
  • 8
  • 41
  • 59
Baris
  • 797
  • 2
  • 10
  • 15
  • 1
    Seriously Its been a year later and the source code for this still hasn't been released. And I can't seem to find this version of the app on the market. Who do you have to talk to at google to get this done? – Terrance Sep 21 '11 at 14:42

7 Answers7

37

Yet another action bar implementation can be found here (shameless plug), https://github.com/johannilsson/android-actionbar. It's implemented as a library project so there's no need to copy-paste resources.

Implementation wise it's built as a widget that extends a RelativeLayout with it own layout for the actions and the bar. This makes it possible to add it to layouts with it own xml snippet.

<com.markupartist.android.widget.ActionBar
    android:id="@+id/actionbar"
    style="@style/ActionBar"
    />

And then later on refer to it in a activity to add actions.

ActionBar actionBar = (ActionBar) findViewById(R.id.actionbar);
actionBar.setTitle("Other");
actionBar.setHomeAction(new IntentAction(this, HomeActivity.createIntent(this), R.drawable.ic_title_home_default));
actionBar.addAction(new IntentAction(this, createShareIntent(), R.drawable.ic_title_share_default));
actionBar.addAction(new ToastAction());
Johan Berg Nilsson
  • 1,634
  • 1
  • 12
  • 11
  • 1
    Johan, this looks like an excellent project. I am however, having trouble getting it to connect correctly with my own code. I have imported your code as a Library project in my Eclipse workspace, have added your project as a 'Library' in the properties for my project and have added a reference in my AndroidManifest.xml. It compiles fine on my machine but upon installation in the emulator, logcat reports that it cannot find any of the resources (it lists them by hex code). Any quick guesses as to what I might have missed? – Sam Svenbjorgchristiensensen Dec 21 '10 at 02:16
  • 1
    There's no need to use , the only thing you have to do is to refer to the action bar project from your main project. From Eclipse you can do that from the properties menu then choose Android and then at the bottom under the Library section add the reference to the action bar project. Library projects also requires somewhat updated Android tools and platforms, more info about library projects and how to refer to a library project can be found in the docs here; http://developer.android.com/intl/zh-TW/guide/developing/eclipse-adt.html#libraryProject – Johan Berg Nilsson Dec 21 '10 at 09:57
  • I've updated my main application project to reference your library project, but my IDE (IntelliJ) won't recognise the `"import com.markupartist.android.widget.ActionBar"` statement or the layout declaration in XML. Do you have any experience getting a library project referenced without using Eclipse/ADT? – ohhorob Jan 08 '11 at 00:42
  • It will now let me "import com.markupartist.android.widget.*" to resolve the `ActionBar` class in a `.java` source file, but the `` tag in a layout doesn't work :( – ohhorob Jan 08 '11 at 01:13
  • I've notice that Intellij tries to validate a lot of things that it shouldn't. I used to use Intellij for Android dev but switched over to Eclipse cause it wasn't really there yet. So I'm sorry I don't know why it complains on that. Next best option would be to copy paste the resources I guess? Update, found this article on library projects with Intellij, http://www.jetbrains.com/idea/webhelp/sharing-android-source-code-and-resources-using-library-projects.html Maybe that could help? – Johan Berg Nilsson Jan 09 '11 at 11:47
  • Hi johan and thanks for your efforts. Great stuff. I followed your steps but I do somehow get three errors stating that the methods getDrawable(), onClick(View) and performAction(View) of Type ... must override a superclass method. Do you have any clue why this might be or any idea how I could fix this? Thanks a lot. bruiser – Bruiser Jun 07 '11 at 18:04
  • It's hard to tell based on that information. Please verify that your ide is has Java 6 set as the compiler, otherwise you might run into problems with override annotations. – Johan Berg Nilsson Jun 08 '11 at 13:04
  • it's under apache 2.0, what does that mean for commercial? do i have to make an about button, since i don't have one – max4ever May 31 '12 at 10:29
23

You might want to take a look at the source code for the Google I/O 2010 schedule application, which is open source and contains an Action Bar implementation:

http://code.google.com/p/iosched/

Trevor Johns
  • 15,682
  • 3
  • 55
  • 54
  • There is an error in the project in SimpleMenuItem.java. The compiler says it does not implement an abstract method from its parent MenuItem. All you have to do is get Eclipse's context menu to fill in an empty implementation for you. Then the project compiles fine. – JoJo Nov 03 '11 at 23:31
20

ActionBarSherlock at https://github.com/JakeWharton/ActionBarSherlock is an Android library for implementing the action bar design pattern using the native ActionBar on 3.0+ and a third-party library on pre-3.0.

Intrications
  • 16,782
  • 9
  • 50
  • 50
10

I'm also waiting hard till Google open sources the Twitter app...but also tweeting Reto Meier didn't bring info about a possible release...anyway.

Regarding QuickActions I found the following interesting links which may potentially be interesting for some of you here:

Have fun!

Juri
  • 32,424
  • 20
  • 102
  • 136
  • Couple of us asked Reto Meier [other googlers] at Droidcon London 2010 about the open sourcing the Twitter app. They said it was up to Twitter. – scottyab Dec 22 '10 at 07:57
  • 1
    @scottyab perfect....good luck then. I just wonder 'cause Twitter proudly posted that Google would open source it on their blog (at the time of announcing the app) and now...more than 1 year later...nothing happened – Juri Dec 22 '10 at 15:07
2

Google suppose to open source twitter app pretty soon ( i hope ) as showcase for all they talk about in this article. If you can't wait - hide title bar. Create layout that looks like that. Include it in all your activities via tag .

Alex Volovoy
  • 67,778
  • 13
  • 73
  • 54
0

There is an Action Bar implementation in Tomdroid, a GPL note taking App which can sync with Tomboy.

See https://code.launchpad.net/~tomdroid-maintainers/tomdroid/main

Rodja
  • 7,998
  • 8
  • 48
  • 55
0

Android 4.x (Ice Cream Sandwich) now includes a native Action Bar: http://developer.android.com/guide/topics/ui/actionbar.html

Android 4.x Design Guidelines: http://developer.android.com/design/patterns/actionbar.html

Camsoft
  • 11,718
  • 19
  • 83
  • 120