该方法getChildFragmentManager()是未定义 [英] The method getChildFragmentManager() is undefined

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

问题描述

我有一个SherlockFragmentActivity,这个活动有一个SectionsPagerAdapter和ViewPager。当我打电话SectionsPagerAdapter的构造与 getChildFragmentManager()方法,它显示我此错误消息:

I have a SherlockFragmentActivity, this Activity have a SectionsPagerAdapter and a ViewPager. When I call the constructor of the SectionsPagerAdapter with getChildFragmentManager() method, it shows me this error message:

该方法getChildFragmentManager()是未定义的类型ViewPagerActivity

The method getChildFragmentManager() is undefined for the type ViewPagerActivity

这是我的code:

public class ViewPagerActivity extends SherlockFragmentActivity implements OnPageChangeListener, OnQueryTextListener{

private SectionsPagerAdapter sectionsPagerAdapter;
private ViewPager viewPager;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.layout_view_pager);

    sectionsPagerAdapter = new SectionsPagerAdapter(getChildFragmentManager(), this);

    viewPager = (ViewPager) findViewById(R.id.pager);
    viewPager.setAdapter(sectionsPagerAdapter);
    viewPager.setOnPageChangeListener(this);

    this.getMovements();

    this.getPrizes();

    this.getVouchers();

    this.createDropdownlist(); 
}

我使用ActionBarSherlock和我使用的更新了Android的支持 - v4.jar。Android的工具 - 添加支持库的在我的项目,也ActionBarSherlock项目

I'm using ActionBarSherlock and I updated the android-support-v4.jar using "Android Tools - Add Support Library" in my project, also on ActionBarSherlock project.

我这样做,因为我需要的,我喜欢用一个页面上我ViewPager一个片段内ListFragment。

I'm doing this because I need to have a ListFragment inside a Fragment that I use like a page on my ViewPager.

推荐答案

getChildFragmentManager()片段的方法,而不是 FragmentActivity 。使用 getSupportFragmentManager() FragmentActivity

getChildFragmentManager() is a method on Fragment, not on FragmentActivity. Use getSupportFragmentManager() on a FragmentActivity.

这篇关于该方法getChildFragmentManager()是未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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