Implementing ActionBar tabs with v4 Fragments API

六月ゝ 毕业季﹏ 提交于 2020-01-01 01:13:14

问题


My app is currently using the Fragments/v4 compatibility package to support Android versions all the way down to 1.6. This means all my Fragments inherit from the compatibility package's version of Fragment. I'm currently trying to rework parts of the app to take advantage of Honeycomb features, like ActionBar.

I already use my own action-bar-like implementation on pre-3.0 devices, and the Honeycomb Action Bar otherwise. This bit isn't an issue.

The problem I have is trying to implement tabs using the ActionBar. ActionBar.TabListener expects the native Fragment and FragmentTransaction classes to work - so trying to use my Fragment classes (which inherit from the compatibility library) doesn't compile.

So, does anyone have any ideas how I can use fragments that use the compatibility package version of Fragment with ActionBar tabs?

tldr: how can I use ActionBar tabs with fragments that inherit from the v4 compatibility library?


回答1:


I asked this question on the android-developers mailing list.

The approach I've taken is the one suggested by CommonsWare, whereby the provided FragmentTransaction parameter is ignored entirely: http://groups.google.com/group/android-developers/msg/d8d84cdd2f753b71



来源:https://stackoverflow.com/questions/5713793/implementing-actionbar-tabs-with-v4-fragments-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!