【问题标题】:Preference Fragment with android.support.v4.app.Fragment带有 android.support.v4.app.Fragment 的偏好片段
【发布时间】:2016-03-10 14:50:44
【问题描述】:

如何在 android.support.v4.app.Fragment 中使用偏好片段? 我尝试使用 android.preference.PreferenceFragment 但出现错误:Wrong 2nd argument type/

FragmentTransaction transaction = getFragmentManager().beginTransaction();
            transaction.replace(R.id.fragment_container, new SettingsFragment());
            transaction.addToBackStack(null);
            transaction.commit();

SettingsFragment 是偏好片段

什么可以解决这个问题?

【问题讨论】:

    标签: android android-fragments android-preferences


    【解决方案1】:

    据我所知,PreferenceFragment 不支持 android.support.v4 库。

    但是,您可以使用 support-v7 库中的 PreferenceFragmentCompat

    如果它确实必须与 support-v4 库一起使用,我建议按照this old thread 的建议将以下项目作为库项目添加到您的应用程序中。

    https://github.com/kolavar/android-support-v4-preferencefragment

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-03-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-22
      相关资源
      最近更新 更多