[android-developers] Using v4 Fragments with v11 ActionBar tabs

2011-04-19 Thread Dave Johnston
I'm having trouble implementing ActionBar tabs whilst also using
backward-compatible Fragments (with the compatibility package).

The main issue being that ActionBar.TabListener expects
android.app.Fragment, and my Fragment classes inherit from
android.support.v4.app.Fragment. Therefore I can't use my Fragments
with the ActionBar on 3.0-and-later devices.

Anyone have any ideas how I can solve or work around this? (besides
just not using tabs)

-dave

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Using v4 Fragments with v11 ActionBar tabs

2011-04-19 Thread Mark Murphy
On Tue, Apr 19, 2011 at 11:10 AM, Dave Johnston john...@gmail.com wrote:
 I'm having trouble implementing ActionBar tabs whilst also using
 backward-compatible Fragments (with the compatibility package).

 The main issue being that ActionBar.TabListener expects
 android.app.Fragment, and my Fragment classes inherit from
 android.support.v4.app.Fragment. Therefore I can't use my Fragments
 with the ActionBar on 3.0-and-later devices.

 Anyone have any ideas how I can solve or work around this? (besides
 just not using tabs)

ActionBar.TabListener does not expect android.app.Fragment. It does,
however, supply an android.app.FragmentTransaction as a parameter,
rather than the Android Compatibility Library implementation of
FragmentTransaction.

What seems to be working for me is to simply ignore the passed-in
FragmentTransaction and use your own. See the FeedsTabActivity in this
project:

https://github.com/commonsguy/cw-advandroid/tree/master/Honeycomb/FeedFragments

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android 3.0 Programming Books: http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en


Re: [android-developers] Using v4 Fragments with v11 ActionBar tabs

2011-04-19 Thread Chris Stewart
As far as I know, you can't use the ActionBar pre-Honeycomb anyway.  So you
wouldn't have a scenario in which you'd be able to use the ActionBar unless
you're targeting Honeycomb.

And to clarify, I don't know much, so I could be completely wrong. :)

--
Chris Stewart
http://chriswstewart.com



On Tue, Apr 19, 2011 at 11:10 AM, Dave Johnston john...@gmail.com wrote:

 I'm having trouble implementing ActionBar tabs whilst also using
 backward-compatible Fragments (with the compatibility package).

 The main issue being that ActionBar.TabListener expects
 android.app.Fragment, and my Fragment classes inherit from
 android.support.v4.app.Fragment. Therefore I can't use my Fragments
 with the ActionBar on 3.0-and-later devices.

 Anyone have any ideas how I can solve or work around this? (besides
 just not using tabs)

 -dave

 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Re: [android-developers] Using v4 Fragments with v11 ActionBar tabs

2011-04-19 Thread Mark Murphy
On Tue, Apr 19, 2011 at 11:19 AM, Chris Stewart cstewart...@gmail.com wrote:
 As far as I know, you can't use the ActionBar pre-Honeycomb anyway.  So you
 wouldn't have a scenario in which you'd be able to use the ActionBar unless
 you're targeting Honeycomb.

No, but you can have an application that uses the Android
Compatibility Library for older devices, yet you want to use the
ActionBar on Honeycomb tablets. In fact, I would expect the vast
majority of Android Compatibility Library apps will take this
approach.

Now, how many of them will want to use tabs on their action bar is
another matter entirely.

-- 
Mark Murphy (a Commons Guy)
http://commonsware.com | http://github.com/commonsguy
http://commonsware.com/blog | http://twitter.com/commonsguy

Android 3.0 Programming Books: http://commonsware.com/books

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en