Action Bar doesn't change back - android

Previously I had changed the android:minSdkVersion to "1", so I lost the Action Bar and just a bar with the app title shows, and now that Ive changed it to "8", the Action Bar is not being shown. Instead it stil shows just the title bar :(
How to get back the action bar?
Help.

As elimirks stated out one possibility is to clean your project before compiling it again.
Much more likely should still be the following:
SDK-version 8 represents Android 2.2 whereas the ActionBar was introduced with Android 3.0 (SDK-version 11), so 8 is not even enough to ensure that. Set it up to 11 and see what happens.
Regardless, to ensure targeting a specific platform or feature (as the ActionBar is) you should use android:targetSDKVersion. This attribute specifies the SDK that your code will be compiled against.
For further reading on that topic:uses-sdk

Related

Cannot set split ActionBar using support libraries

I have searched a lot on the internet but I still can't set split action bar. I also attempted official documentation's methods but nothing works.
I'm building app with minSdkVersion = 9 and targetSdkVersion = 21 and using AppCompat Theme I successfully changed the color of actionbar and text but cannot add split ActionBar.
I added uiOptions = "splitActionBarWhenNarrow" in manifest file and also added meta-data for backward support but split action bar is still not visible on either narrow or wide screens.
appcompat-v7 as of version 21 no longer supports the split action bar, as Android 5.0 no longer supports the split action bar.
If you want that sort of thing, you have to do it yourself, via a Toolbar or something that you position at the bottom of the screen.

Removing title bar changes display of ProgressDialog

In my android app, which is just a webview displaying a responsive web site, I want to remove the title bar so I add this to the application section of the manifest XML.
android:theme="#android:style/Theme.NoTitleBar"
The problem is, I get two totally different ProgressDialog UI treatments. The one with the title bar is much nicer so I would like to keep it, but I don't want a title bar.
I believe this relates to the theme. I want to keep the theme, just not the title bar... at least I think. How do I keep the nicer styling, and hide the title bar instantly (not programmatically once the activity starts, that shows the title bar briefly)?
The problem is that Theme.NoTitleBar comes from pre-Honeycomb era, so it shows a pre-Honeycomb dialog.
If your app is API 11 or up you can simply switch by the Holo version of it (I honestly don't remember the name).
Or to support both older and newer device you'll have to use this type of approach Different Theme for different Android SDK versions to apply Theme.NoTitleBar to old devices and its holo counterpart for newer devices.
happy coding.

How can I use a contextual action bar with the Android support library?

I have a ListView in my ActionBarActivity that has items that can be long-pressed for additional actions.
I currently am using registerForContextMenu and showing an ugly popup dialog, so I want to change it to use a contexual action bar.
How can I do this? CHOICE_MODE_MULTIPLE_MODAL as well as a few other things seem to be API 11+.
What you want to use is ActionMode, http://developer.android.com/reference/android/support/v7/view/ActionMode.html, to implement the contextual action bar. The ActionMode is available in the ActionBarCompat library. Specifically you use ActionBarActivity#startSupportActionMode.
You can get a quick introduction in this document, http://android-developers.blogspot.com/2013/08/actionbarcompat-and-io-2013-app-source.html. See the section entitled "7. Add ActionMode callbacks".
A more complete tutorial is available here, http://developer.android.com/guide/topics/ui/menus.html#CAB.
The Android API Guide for menus (same page that Matt cited) states that:
Note: The contextual action mode is available on Android 3.0 (API level 11) and higher and is the preferred technique for displaying contextual actions when available. If your app supports versions lower than 3.0 then you should fall back to a floating context menu on those devices.
If this is still true, then it means that Android does not support contextual action bars below API level 8. Can anyone please confirm if they have used it for Froyo or below?

Android ActionBar Not Appearing

I know, this sounds dumb, but bear with me.
I use the following
android:minSdkVersion="8"
android:targetSdkVersion="17"
android:Theme.Holo"
When I run my app on 2.2 emulator, the menu button brings up my menu.
Whhen I run my app on 4.2 emulator, should the action bar not automatically be activated? I can see program icon + title. I have added some menu items like this:
<item android:id="#+id/itemShare" android:title="#string/titleShare"
android:icon="#android:drawable/ic_menu_share"
android:showAsAction="ifRoom"></item>
I then have defined
onCreateOptionsMenu
all my activies inherit from.
Yet, I see nothing "action bar" icons when running my app in 4.2 emulator. I must be missing something obvious.
I am very new to Android and Eclipse, but I am slightly confused of above. The way I do it, should that not be the way to get pre/post honeycomb compability assuming one does not want to use ActionbarSherlock?
Whhen I run my app on 4.2 emulator, should the action bar not automatically be activated?
Yes.
I can see program icon + title.
That is the action bar.
Yet, I see nothing "action bar" icons when running my app in 4.2 emulator. I must be missing something obvious.
Your emulator has decided that there is insufficient room to show the icons, so they are in the overflow. Depending on your emulator configuration, you activate the overflow by pressing the MENU button or by pressing the ... affordance in the action bar on the right.
The way I do it, should that not be the way to get pre/post honeycomb compability assuming one does not want to use ActionbarSherlock?
Yes.

Honeycomb Action Bar not showing (baffled)

I am completely baffled. I created an application with minSDK=4 and targetSDK=11. Compiled and ran on the Xoom tablet. I am not getting an Action Bar and cannot figure out what I have done wrong. I have been staring at the screen for hours and don't know what I have done that would have caused the bar to disappear. Help! Any suggestions on why I am not seeing the Action Bar?
You need to declare android:theme="#android:style/Theme.Holo" for Activity in Manifest xml.
The dev guide says like you only need to set the target SDK version, but it does not work.
I'm quoting from here:
"If you are using the Support Library APIs for the action bar, then you must use (or override) the Theme.AppCompat family of styles (rather than the Theme.Holo family, available in API level 11 and higher)."
I used android:theme="#style/Theme.AppCompat" in my manifest and the action bar appeared.
Romulus' answer, forcing the App to use the Holo theme will work but it results in a compile error if your minSDK is less than 11.
Check if you have defined a theme in the AndroidManifest:
android:theme="#style/XXXXXXXXXXXXXXXXX"
That means you're forcing the App to use a particular theme, so the action bar might not appear on Honeycomb or higher devices (it depends if the theme specifies an action bar). Delete this statement to cause the App to use the default device theme, so the Settings menu appears on pre-Honeycomb devices and the action bar appears on post-Honeycomb devices. Job done. Hope this helps.

Categories

Resources