如果我支持 SDK 15,我应该使用 support-v4 Fragment
而不是 Fragment
吗?
我正在尝试使用 FragmentSupport.shouldShowRequestPermissionRationale(this)
并实现新的 M 权限模型,但它需要一个 fragment 。
例如:
import android.support.v4.app.Fragment;
public class MyBaseFragment extends Fragment {
public ... {
if (FragmentCompat.shouldShowRequestPermissionRationale(this)){ // ERROR, needs Fragment not v4 Fragment
....
}
}
}
fragment 兼容性:http://developer.android.com/reference/android/support/v13/app/FragmentCompat.html
最佳答案
如果您使用的是选项卡(即 ViewPager)等布局,则需要支持库。在“只有” fragment 和 minSDK 15 的情况下,它们不是必需的。顺便说一句,使用支持库是很好的,因为它不需要太多的努力,并且您可以在以后根据需要进行更改。详细可以看documentation在这里查看您的项目是否需要它。
关于android - support-v4.Fragment 与 Fragment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32722740/