使用getSupportFragmentManager()内preferenceActivity [英] Use getSupportFragmentManager() Inside PreferenceActivity

查看:223
本文介绍了使用getSupportFragmentManager()内preferenceActivity的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的自定义的 ConfigActivity 延伸preferenceActivity(从机器人。preference。preferenceActivity )。这项活动的布局包含< ListView的机器人:ID =@机器人:ID /列表... 。这里面的布局,我需要以编程方式添加/更换一对夫妇我已经创建的其他片段扩展 android.support.v4.app.Fragment

I have my custom ConfigActivity which extends PreferenceActivity (from android.preference.PreferenceActivity). The layout for this activity contains a <ListView android:id="@android:id/list".... Inside this layout, I need to programmatically add/replace a couple of other Fragments I have created that extend android.support.v4.app.Fragment.

不过,Eclipse的说:

However, Eclipse says:

的方法getSupportFragmentManager()是未定义的类型ConfigActivity

我试图取代它只是 getFragmentManager(),但下面的调用:

I tried replacing it for just getFragmentManager(), but the following call:

ft.add(R.id.fHeader,新MyCustomFragment());

导致以下错误:

在类型FragmentTransaction Add方法(INT,片段)是不适用的参数(INT,MyCustomFragment)

是我不能用我的自定义碎片唯一的选择,扩展内部ConfigActivity支持库的片段类?

Is my only option to NOT use my custom Fragments that extends the support library's Fragment class inside ConfigActivity?

推荐答案

我想你会需要让你的活动延长FragmentActivity或FragmentActivity的一些子类,如果您使用的是android.support.v4.app.Fragment与片段工作。
其他选项可以让你的最低SDK版本设置为12,并检查您code,而无需使用支持库。

I think you will need to make your activity extend FragmentActivity or some subclass of FragmentActivity to work with Fragments if you are using android.support.v4.app.Fragment. Other option can be to make your minimum sdk version set to 12 and check your code without using support libraries.

这篇关于使用getSupportFragmentManager()内preferenceActivity的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆