I'm just new in android.. i just wanna ask how to create a actionbar ??.. without using a import com.markupartist.android.widget.Actionbar that comes from a project that I have been downloaded.. Thank you .. I'm using a 2.2 version
You'll get a ActionBar by default, if your app runs HC+ (and you use the holo theme). However, since the ActionBar got introduced with HC (API Level 11) you have to use ActionBarSherlock, if you want to use it on pre HC devices.
From the Android Developers guide:
Beginning with Android 3.0 (API level 11), the action bar is included
in all activities that use the Theme.Holo theme (or one of its
descendants), which is the default theme when either the
targetSdkVersion or minSdkVersion attribute is set to "11" or greater.
Thus you simply need to set
<uses-sdk android:minSdkVersion="11" />
or
<uses-sdk android:targetSdkVersion="11" />
in your AndroidManifest.xml. You can, of course, set either to higher than 11 as needed, but 11 is the minimum for automatically including the ActionBar.
If you want to use ActionBar in your project, then just download it from this link
Download Actionbar library project
Now import this project into your eclipse.
After that set it as library in your project.
Its done...
Related
I have a problem with ActionBar.
I set minsdk in AndroidManifest to 14. Next I create Activity (BlankActivity), thats create MyACtivity class which extend ActionBarActivity and import android.support.v7.app.ActionBarActivity. I think that this library need only if you use sdk level 7 or lower.
This import correctly? Or i need use another extend class?
And I try change extend class to Activity, but its does not create ActionBar on Activity.
How add ActionBar on this Activity?
P.S. I was misled, because on my sdk function getActionBar must work, its NullPointer, because my app use this strange import. A can use getSupportActionBar, but its strange use support library for sdk 7 to create Application for sdk 14 or higher.
P.S.S. Thanks!!
If anybody have same problen, there is some links about toolbar:
http://www.101apps.co.za/index.php/articles/using-toolbars-in-your-apps.html
Why was ActionBarActivity deprecated
I have a problem with ActionBar.
Who doesn't ;)
I think that this library need only if you use sdk level 7 or lower.
The appcompat-v7 library used to backport API 14 Action Bar to platforms below that. APIs 7 through 13 used this reimplementation, APIs from 14 used native Action Bar.
Since Lollipop the appcompat-v7 always uses it's own implementation of Action Bar and backports Material theme from Lollipop.
This import correctly? Or i need use another extend class?
To have the Action Bar with appcompat-v7 your activity class must extend AppCompatActivity (previously ActionBarActivity) and it's theme must descend from Theme.AppCompat.* family.
And I try change extend class to Activity, but its does not create ActionBar on Activity.
Native activities on Lollipop don't have any Action Bar by default. You would supply it by having a Toolbar widget in your layout and calling setActionBar(Toolbar). Similar approach can also be used with appcompat-v7 (if you use a theme without default action bar) by calling setSupportActionBar(Toolbar).
How add ActionBar on this Activity?
[...] but its strange use support library for sdk 7 to create Application for sdk 14 or higher.
It's perfectly OK, the goal is to make the app look the same from API 7 to API 22. Appcompat-v7 now backports not only the Action Bar but Material theme as well.
It's better you start with a working example. Just check in you android sdk installation for the folder \samples\android-21\ui\ActionBarCompat-Basic.
The use of the support library is correct, just follow the ActionBar Developer guide here.
I just wanted to give my actionbarsherlock tabs another color. Therefore, I found this interesting article: Styling the Actionbarsherlock tabs
Now, my problem is that for me it only works for API level before 11. What am I doing wrong? I implemented the code from the solution just like that.
One other thing that I did, was increasing my API level (from 7 to 11) because this line from the code in the article
<item name="android:actionBarTabBarStyle">#style/Theme.app.tabbar.style</item>
produced this error:
android:actionBarTabBarStyle requires API level 11 (current min is 7)
Any ideas?
For just API 11+ you can create a folder in res called values-v11 and make a style file in there, then only those styles will be applied if the API is level 11 or greater.
In my app I have a some fragments that I switch between manually in the phone version and I want to show the < arrow in the ActionBar. To do this I know I need to call actionBar.setDisplayHomeAsUpEnabled(true); but that breaks in lower api levels. I can check the api level and only call it in 3.0+ but LINT gives me an error. Is it alright to just suppress the error? What's the right way to do this?
First setup ActionBarSherlock for compatibility for Android 2.1+ for the ActionBar:
http://actionbarsherlock.com/
https://github.com/JakeWharton/ActionBarSherlock
One you have set up this great compatibility library, you can now use in your Fragment:
getSherlockActivity().getSupportActionBar().setDisplayShowTitleEnabled(true);
Make sure you extend your Fragments to SherlockFragments:
public class TestFragment extends SherlockFragment
If you need anymore help, let me know I have set this up many times!
Regards,
Use Jake Wharton's action bar sherlock library which is more flexible to support in all versions.
https://github.com/JakeWharton/ActionBarSherlock
If you need use the actionbar in android 3 and higher only, you can suppress warnings (be shure that min api level is set). But else you have to use SharlockActionBar library.
I want to build a tabbed interface, so I took the Tabs3 view from the API demos sample project, however for some reason the Holo theme is not being applied to my app It should look like this But it looks like this.
This is the relevant bit in my manifest:
<application
android:label="#string/app_name"
android:icon="#drawable/ic_launcher"
android:theme="#android:style/Theme.Holo.Light">
<activity android:name="Tabs"
android:label="#string/app_name" >
At this point all I have done is copy over the Tabs3 class (renamed to Tabs), List1, List8 and Controls1, along with the related layouts and strings.
Thanks for the help!
You use the wrong tabs. Here is a full tutorial how to use ActionBar.Tab. Click me!
Remind, ActionBar.Tab is only available on API Level 11 or higher, if you want to support Android API Level 10 (Android 2.3) or lower, you have to use ActionBarSherlock.
The Holo theme is only available in Android since API Level 15. If you want to use the Holo theme on lower API levels you should take a look at HoloEverywhere.
Holo Theme is available for API level 11 and up. That might be the reason for it not working. If anything you can use ActionBarSherlock for lower API levels.
I'm building an Android app that should be able to run on Android 2.1 and above. The minSdkVersion is set to 7, and the targetSdkVersion is set to 14. In order to have ActionBar functionality, I am using the ActionBarSherlock library and setting the theme of the application to a derivative of Theme.Sherlock (etc.), as required.
Aside from providing an ActionBar, I notice that when I run the app on a Honeycomb/ICS device, some of the other widgets and dialogs now have a different (i.e. Holo) appearance. I want to have an ActionBar but keep the normal, non-Holo Android theme - the Holo styling does not fit well with the rest of the app. EditText views in particular look significantly different.
I see that ActionBarSherlock defines some custom themes in values-11 (Honeycomb) and values-14 (ICS), which inherit from Theme.Holo. There are also custom styles in values-14 which map the ABS styles to the native ones (since the native ActionBar is used in ICS+).
I have found that I have to do at least the following things:
Disable the custom themes for values-11 and values-14 - this stops Holo widgets/dialogs appearing.
Disable the use of the native implementation of the ActionBar for ICS+ - this stops the crashing on ICS since it relies on the native ActionBar provided as part of Holo theme. This requires modification of the library.
Disable the custom styles for values-14 - this messed with the look/styling of the compatibility ActionBar.
I am not sure if there are other issues that I have missed. Has anyone found a good way to use the non-Holo Android theme with ActionBarSherlock, without modifying the library? Are there any problems with using the compatibility ActionBar in ICS and above?