Dzh*_*eyt 5 android preferenceactivity android-fragments
我有自定义ConfigActivity
,它扩展了PreferenceActivity(来自android.preference.PreferenceActivity
)。此活动的布局包含<ListView android:id="@android:id/list"...
。在此布局内,我需要以编程方式添加/替换我创建的其他几个extends Fragment android.support.v4.app.Fragment
。
但是,Eclipse表示:
The method getSupportFragmentManager() is undefined for the type ConfigActivity
。
我尝试将其替换为just getFragmentManager()
,但是以下调用:
ft.add(R.id.fHeader, new MyCustomFragment());
导致以下错误:
The method add(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (int, MyCustomFragment)
我唯一的选择是不使用自定义片段来扩展ConfigActivity中支持库的Fragment类吗?
我认为如果您使用 android.support.v4.app.Fragment,则需要使您的活动扩展 FragmentActivity 或 FragmentActivity 的某些子类才能使用 Fragment。其他选项可以是将最低 sdk 版本设置为 12 并在不使用支持库的情况下检查代码。
归档时间: |
|
查看次数: |
5414 次 |
最近记录: |