1

I have successfully imported ActionbarSherlock library to my own project, and I can already see the sherlock made action bar in my application when I run my project.

But, now, everything is by default. How can I make a custom action bar with sherlock library ? Any tutorials available?

Jake Wharton
  • 75,598
  • 23
  • 223
  • 230
Leem.fin
  • 40,781
  • 83
  • 202
  • 354
  • I made a template for custom ActionBarSherlock style. See this post: http://stackoverflow.com/questions/9757400/setting-actionbarsherlock-theme-for-android-app/#answer-14366287. – petrnohejl Jan 16 '13 at 19:25

2 Answers2

6

I have never used the ActionBarSherlock library (I have used Greendroid in the past, but now I use ActionBarCompat for pre-honeycomb devices, which is great and very easy to use.).

That being said, I suggest you to look a the res/values folder where you will probably find all the default styles (probably wrapped in a custom theme which extends the default android theme). From there, you just have to extend that Sherlock theme and override the styles with your own.

If you want a good tutorial on how styles and themes work in Android, I suggest you to read the official documentation.

Edit

In order to use ActionBarCompatyou have to do the following:

  1. Import the project from the samples directory (inside the directory where the android SDK is installed). (Note that you should download the latest SDK).
  2. Remove MainActivity from the build path (right click on the class -> Build Path -> Exclude).
  3. Set the project as a project library (right click on the project -> properties -> android -> check Is Library).
  4. Add this project as a library for your app (right click on the project -> properties -> android -> click on Add in the Library section).
  5. Make your activities inherits from ActionBarActivity.
  6. Set the theme as @style/appTheme in the manifest.

Finally, don't forget that the action bar actions are in the res/menu/main.xml file. And same thing for the colors and styles, look at the res/valuesdirectory.

Amokrane Chentir
  • 29,907
  • 37
  • 114
  • 158
  • Hi, ActionBarCompat looks great, but how to use it, the link you provide only contain source code. any tutorials about it??? – Leem.fin Feb 10 '12 at 11:04
  • And where can I download the source code as a compressed file for the ActionBarCompat link you provided?? – Leem.fin Feb 10 '12 at 11:06
  • if I use ActionBarCompat as a library for my own project, does the final build APK file of my own project include the ActionBarCompat ? – Leem.fin Feb 10 '12 at 11:39
  • @ Amokrane, I did your steps, and got error in my own project "No resource found that matches the given name 'android:style/Theme.Holo.Light'", is it because my own project built target is Android 2.1 API 7?? – Leem.fin Feb 10 '12 at 11:58
  • @Leem.fin Yes, you have to set the build target to a version higher than 11 actually (honeycomb). – Amokrane Chentir Feb 10 '12 at 13:21
0

For some reason Amokrane's answer wasn't working for me, so here's how I solved it for anyone else that is having issues. I will simply copy and update Amokrane's answer

In order to use ActionBarCompatyou have to do the following:

  1. Import the project from the samples directory (inside the directory where the android SDK is installed). (Note that you should download the latest SDK).
  2. Remove MainActivity from the build path (right click on the class -> Build Path -> Exclude).
  3. Set the project as a project library (right click on the project -> properties -> android -> check Is Library).
  4. Add this project as a library for your app (right click on the project -> properties -> android -> click on Add in the Library section). Build the project and copy /bin/ActionBarCompat to you projects /libs directory.
  5. Copy the contents of ActionBarCompat/res to your project /res directory, being careful not to over-write any of your own resources.
  6. Make your activities inherits from ActionBarActivity.
  7. Set the theme as @style/appTheme in the manifest.

I hope this helps!

n.collins
  • 343
  • 1
  • 9