Skip to main content

Posts

Showing posts with the label actionbar

getActionBar() returns null

I'm having an odd problem. I am making an app with targetsdk 13. In my main activity's onCreate method i call getActionBar() to setup my actionbar. This works fine when running on the Android 3.2 emulator, but when using Android 3.0 and 3.1 the getActionBar() method returns null. I find this extremely odd, and i cannot see any reason why it would do so. Is this a bug with the emulators or is there something i need to do, in order to ensure that my application has an actionbar? SOLUTION: I think I've found a solution for this problem. I wasn't using the setContentView to set a layout for the activity. Instead I was using fragmentTransaction.add(android.R.id.content, mFragment, mTag) to add a fragment to the activity. This worked fine in 3.2, but in earlier honeycomb versions the action bar is apparently not set if you don't use the setContentView in the onCreate() method. So I fixed it by using the setContentView() method in my onCreate() method and ju

Overriding android:ellipsize on ActionBar subtitle

My activity makes use of the ActionBar.setSubtitle function to display the currently displayed file system location's full path. This means that the substring towards the end of the subtitle is more relevant than the beginning, so I thought I would override the ActionBar style to ellipsize text at the start, rather than the end, like so: res/values/themes.xml <style name="Theme.Holo" parent="android:Theme.Holo"> <!-- Action bar styles --> <item name="android:actionBarStyle">@style/Widget.Holo.ActionBar</item> </style> res/values/styles.xml <style name="Widget.Holo.ActionBar" parent="@android:style/Widget.Holo.ActionBar"> <item name="android:subtitleTextStyle">@style/TextAppearance.Holo.Widget.ActionBar.Subtitle</item> </style> <style name="TextAppearance.Holo.Widget.ActionBar.Subtitle" parent="@android:style/TextAppearance.Ho