ActionBarSherlock doesn't show ActionItems when using dialog theme - android

I am trying to update my app with the new ActionBar paradigm. I want to keep compatibility backwards though, as my largest user base is still on Gingerbread.
To that end, I am trying to integrate ActionBarSherlock into my app.
My app is designed to use the dialog theme, so when I integrated ABS, I tried to use the corresponding dialog theme as so in my AndroidManifest.xml:
<application android:theme="#style/Theme.Sherlock.Dialog" >
My ActionItems would not show up though, and only appeared as old-school menu items (meaning they were completely inaccessible on my tablet). Looking at the samples in the ABS download, I decided to try changing my app and removing the .Dialog qualifier, changing my AndroidManifest.xml to:
<application android:theme="#style/Theme.Sherlock" >
Once I did that, the menu items moved from the menu to the ActionBar, where I expected and want them to be. So it would seem that, with default conditions, ActionItems are not enabled when using the .Dialog theme.
Is there any way to enable this behavior, so that the menu items would show in the ActionBar as expected while still using the dialog theme?

Related

Android theme in library project

I have a library project providing a few activities. Some are immersive, and I need the action bar to be created. On the other hand, the clients using the library must be able to customize its theme (mainly the colors).
One of my clients is using the Theme.AppCompat.Light.NoActionBar theme, which removes the action bar from my activities.
Is there a way to ensure that the action bar will be shown (so, my activities' themes have to inherit from Theme.AppCompat.Light.DarkActionBar), while leaving the colors customizable?
Programmatically creating the action bar would be fine, but I'm not sure that this is possible, right?
EDIT: It works if my client declare the library's activities in their manifest, and set a DarkActionBar theme on each. But I'd really prefer to avoid that solution, as currently they don't have to declare our activities thanks to the manifest merger.

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.

Translucent icons in ActionBar when disabled: only on my phone?

I'm using ActionBarSherlock on my app and when I disable some MenuItem in the ActionBar the icon turns translucent on my phone (HTC One X running stock Android 4.0.4) but I haven't seen this behavior in any other phone or emulator.
Am I right in assuming this behavior is not the default one for the native ActionBar? I like the idea though... It warns the user that the MenuItem is not enabled for some reason (in my case, it's a save button and if at least one field is not filled, it disables the button).
I was thinking in providing myself a translucent icon and set it manually when the MenuItem is disabled. This will work on every Android version, native ActionBar or not. The problem is that on my phone (or any other with the same behavior for that matter), it will be twice as translucent and I don't want that.
Any ideas on how can I properly achieve this effect?
I think that the problem is on the Theme, you are applying the default theme. So, HTC override default theme resources, i think you have to create a custom theme and change the item_background to the default one on sdk resources.
<item name="selectableItemBackground">#android:drawable/item_background</item>
you would have to set the background to be independent of the theme. In the .xml file you could set :
android:background="?android:attr/listSelector"
on the view where you want the color.

PhoneGap - Styles and themes in Android app

I'm building an Android app using PhoneGap, and would like to make the copy/share menu that shows up after a long click on text to overlay the app. To do so, I have to set android:windowActionBar to true. This is what docs say:
Beware that hiding and removing the action bar causes your activity to
re-layout in order to account for the space consumed by the action
bar. If your activity regularly hides and shows the action bar (such
as in the Android Gallery app), you might want to use overlay mode.
Overlay mode draws the action bar on top of your activity layout
rather than in its own area of the screen. This way, your layout
remains fixed when the action bar hides and re-appears. To enable
overlay mode, create a theme for your activity and set
android:windowActionBarOverlay to true.
So I tried to apply this theme:
<resources>
<style name="AppTheme" parent="android:Theme.Holo.Light">
<item name="android:windowActionBarOverlay">true</item>
</style>
</resources>
to my application:
<application
android:icon="#drawable/icono_p"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
with no success.
Is there any way to set android:windowActionBar to true in a PhoneGap application?
EDIT:
The theme is actually being applied, but it just doesn't work as expected, the bar keeps resizing the app
I am pretty sure you would have to write a plugin for that for lower android versions. I am not sure since when this function is available but on my ICS 4.0 i can just copy and share any text out of any phonegap app without declaring anything special. its a system function and it should just work the same way you would copy and share text out of a standard browser.
what are you testing it on and which version?
Solved it. The problem was that the copy/share menu is not an action bar, but a contextual action bar shown when the contextual action mode starts. So, instead of android:windowActionBar, the property to be set to true is android:windowActionModeOverlay

Hide Actionbar, Show Options Menu

I have a non-market app that was built to run on a specific device. Originally, this was on a device running 2.2, but now the app is targeting a specific device on 3.1 and I am adding in support for the Action Bar.
One of the apps Activities is required to be full-screen and have hidden the status bar and the Action Bar. This is achieved using the following in the manifest:
<activity
android:name=".activity.EditorActivity"
android:label="#string/activity_edit"
android:theme="#style/Canvas">
Which references this style:
<style name="Canvas" parent="#android:style/Theme.NoTitleBar.Fullscreen">
<item name="android:windowBackground">#color/bg_white</item>
</style>
So, after moving to 3.1, the effect works, in that the Activity is fullscreen, and everything is hidden as needed, but this of course hides the options menu from populating the Action Bar.
I know that if I leave the android:targetSdkVersion="8", the options menu is shown in the bottom navigation, but this seems like a bit of a hack - is there any other way or 'best practice' for this? I basically have to set android:targetSdkVersion="12" to ensure the app works and isn't put onto older devices so this won't be a permanent solution.
I've decided to stop trying to swim upstream and have switched to using a translucent Action Bar that is overlaid - it works perfectly and is exactly what I had been doing prior to 3.x with my custom solution.
Custom Translucent Android ActionBar

Categories

Resources