【发布时间】:2017-08-06 10:15:49
【问题描述】:
我开始将我的应用程序更改为Material design。
我已将我的 Activity 更改为 ActionBarActivity 并将我的主题更改为 AppCompat,以便能够为 ActionBar 着色并使用 AppCompat 导航抽屉。
我在我的 Activity 中切换 Fragments,这些 Fragments 通过t 添加到 backstack 中
getSupportFragmentManager()
.beginTransaction()
.replace(...)
.addToBackStack(null)
.commit();
由于 AppCompat,我必须使用 SupportFragmentManager。因此,我必须使用支持库中的android.support.v4.app.Fragment。
问题:
我也在使用PreferenceFragment,它不包含在支持库中。因此,我不能将片段添加到后台堆栈。
错误:FragmentTransaction 类型中的方法 replace(int, Fragment, String) 不适用于 Arguments (int, SettingsFragment, String)
我现在使用的解决方案是library。我不想使用它,因为我的目标是 API 14。
有没有办法可以将 PreferenceFragment 与 SupportFragmentManager 一起使用?
【问题讨论】:
标签: android android-fragments android-preferences