Android title bar/action bar

1,428 views
Skip to first unread message

jacco

unread,
Aug 16, 2011, 10:27:08 AM8/16/11
to phonegap
In the OnCreate method of DroidGap this is called:

requestWindowFeature(Window.FEATURE_NO_TITLE)

Which I assume causes an inability to show the Action Bar when my app
is running on a honeycomb device..
Any thoughts?

Simon MacDonald

unread,
Aug 16, 2011, 2:34:14 PM8/16/11
to phon...@googlegroups.com
In your manifest file do you have?

<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="11" />

Setting the target SDK to 11 should get it to show.

Simon Mac Donald
http://hi.im/simonmacdonald

> --
> You received this message because you are subscribed to the Google
> Groups "phonegap" group.
> To post to this group, send email to phon...@googlegroups.com
> To unsubscribe from this group, send email to
> phonegap+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/phonegap?hl=en?hl=en
>
> For more info on PhoneGap or to download the code go to www.phonegap.com
>

jacco

unread,
Aug 16, 2011, 4:13:59 PM8/16/11
to phonegap
yep, have that but still a no show..

On 16 aug, 20:34, Simon MacDonald <simon.macdon...@gmail.com> wrote:
> In your manifest file do you have?
>
> <uses-sdk android:minSdkVersion="4" android:targetSdkVersion="11" />
>
> Setting the target SDK to 11 should get it to show.
>
> Simon Mac Donaldhttp://hi.im/simonmacdonald

mikesir87

unread,
Aug 29, 2011, 8:54:56 AM8/29/11
to phonegap
I just ran into the same thing. I found a solution, although it might
not be the best/easiest. What I did was I took the source code for
DroidGap (found here: https://github.com/phonegap/phonegap-android/blob/master/framework/src/com/phonegap/DroidGap.java)
and made a DroidGap_Modified class. I then commented out the line of
code you noticed earlier. In the activity you're using to initalize
everything, I have something like this:

super.onCreate(savedInstanceState);
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
super.init();

ActionBar bar = getActionBar();
bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
bar.addTab(bar.newTab().setText("Home").setTabListener(new
CustomTabListener()));

bar.addTab(bar.newTab().setText("Something").setTabListener(new
CustomTabListener()));

Just to note, you have to either call
getWindow().requestFeature(Window.FEATURE_ACTION_BAR) or super.init()
before you can access the ActionBar. super.init() fires
setContentView, which is needed to build the ActionBar. Otherwise,
you'll get a NPE. I imagine the requestFeature does the same thing
too.

Hope it helps!

jacco

unread,
Aug 31, 2011, 3:41:30 AM8/31/11
to phonegap
Yes, this is probably the best solution at the moment. However, I
don't feel too comfortable in overriding DroidGaps oncreate method and
not calling it's super anymore. Things tend to change in DroidGap's
oncreate method over different versions :-)
It would however be very nice if Phonegap would use layout xml files
instead of hardcoding the webviews layout. Would make things all the
more flexible IMHO..



On Aug 29, 2:54 pm, mikesir87 <mikesi...@gmail.com> wrote:
> I just ran into the same thing.  I found a solution, although it might
> not be the best/easiest.  What I did was I took the source code for
> DroidGap (found here:https://github.com/phonegap/phonegap-android/blob/master/framework/sr...)

Simon MacDonald

unread,
Aug 31, 2011, 9:00:51 AM8/31/11
to phon...@googlegroups.com
There is a bit of a complication with using layout.xml files. If we do switch to the layout.xml file then PhoneGap would have to become an Android LIbrary project instead of a jar file. This would allow the app you are building to access the layout.xml file correctly. 

If not you'd need to include the xml file in your res/layouts directory then go into the PhoneGap source and add an import for com.my.app.name.R so the layout file can be referenced properly. That would be a bit of a pain eh.

Simon Mac Donald
http://hi.im/simonmacdonald


jacco

unread,
Aug 31, 2011, 9:09:20 AM8/31/11
to phonegap
> If not you'd need to include the xml file in your res/layouts directory then
> go into the PhoneGap source and add an import for com.my.app.name.R so the
> layout file can be referenced properly. That would be a bit of a pain eh.

What about having the onCreate call a setLayout method which can then
be overridden ?

Simon MacDonald

unread,
Aug 31, 2011, 9:16:09 AM8/31/11
to phon...@googlegroups.com
Possibly. Dave is about to push some changes to DroidGap to make plugins even better. I'm going to see what things look like after the changes and I suppose I should get back to vacation :)

Simon Mac Donald
http://hi.im/simonmacdonald



--

jacco

unread,
Aug 31, 2011, 9:22:19 AM8/31/11
to phonegap
> I suppose I should get back to vacation :)

Right you are! Have a good one.

Cheers.
Reply all
Reply to author
Forward
0 new messages