我在我的应用程序中遇到了动态表单的问题,该应用程序适用于 Android 2.1 及更高版本。我知道自 API 级别 11(Android 3.0 Honeycomb)以来有新的 Fragment API,但我也读过一篇文章 - http://android-developers.blogspot.com/2011/03/fragments-for-all.html 说明Fragment Api 也适用于 API 级别低于 11 的情况,即所谓的兼容性包。我已经通过SDK安装了它,但我无法在我的应用程序中使用它,例如我无法导入android.app.FragmentManager
,应用程序不知道它。
你知道如何解决吗? Fragment API 真的适用于较旧的 API 级别吗?如果是这样,如何让他们继续?或者还有其他像 Fragments API 这样的解决方案吗?如果可能的话,我将需要动态生成的表单
I have came across a problem for dynamic forms in my app, which is suited for Android 2.1 and above. I know there is new Fragment API since API level 11 (Android 3.0 Honeycomb), but also I have read an article - http://android-developers.blogspot.com/2011/03/fragments-for-all.html stating Fragment Api is available also for API level lower then 11 in, so called, Compatibility package. I have installed it via SDK, but I am not able to use is in my App, e.g. I cannot import android.app.FragmentManager
, application doesn't know it.
Do you know, how to solve it? Is Fragment API truly available for older API levels? If so, how to make them going? Or is there any other solution like Fragments API? I will need for dynamic generated forms if possible
发布评论
评论(3)
Android Studio:
添加支持兼容性包 v4: 的依赖项,
然后使用
import android.support.v4.app.Fragment;
而不是import android.app。 Fragment;
在导入中。Android Studio:
Add a dependency for support compatibility package v4:
and then use
import android.support.v4.app.Fragment;
instead ofimport android.app.Fragment;
in imports.您需要将包添加到构建路径。
You need to add the package to the build path.
使用 ActionBarSherlock。它附带了很多工作示例。
Use ActionBarSherlock. It comes with a lot of working examples.