2016-07-22 55 views
0

我有這樣的代碼:空白viewpager時回到了那個活動

... 
ArrayList<View> views = new ArrayList<>(); 
      ArrayList<String> titulos = new ArrayList<>(); 
      views.add(viewPlan); 
      views.add(viewPerfil); 
      titulos.add("Planes"); 
      titulos.add("Perfil"); 

      ViewPager oPager = (ViewPager) getView().findViewById(R.id.pager); 
      oPager.setOffscreenPageLimit(3); 
      oPager.setAdapter(new FormAdapter(((FragmentActivity)getActivity()).getSupportFragmentManager(), views, titulos)); 

與此適配器:

class FormAdapter extends FragmentStatePagerAdapter { 

     List<SolapaSocioFragment> solapas; 
     ArrayList<View> views = new ArrayList<>(); 
     ArrayList<String> titulos = new ArrayList<>(); 

     public FormAdapter(FragmentManager fm, ArrayList<View> views, ArrayList<String> titulos) { 
      super(fm); 
      solapas = new ArrayList<SolapaSocioFragment>(); 
      this.views = views; 
      this.titulos = titulos; 
      for (int i = 0; i < views.size(); i++){ 
       solapas.add(new SolapaSocioFragment().newInstance(views.get(i))); 
      } 
     } 

     @Override 
     public android.support.v4.app.Fragment getItem(int position) { 
      return new SolapaSocioFragment().newInstance(views.get(position)); 
     } 

     @Override 
     public int getCount() { 
      return views.size(); 
     } 

     @Override 
     public CharSequence getPageTitle(int position) { 
      return titulos.get(position); 
     } 
    } 

視圖尋呼機顯示的看法,但是當我去行吟詩人的活動,並按回按鈕的意見是空白的,我看到谷歌,問題是我必須使用getChildFragmentManager()而不是(FragmentActivity)getActivity())。getSupportFragmentManager()但childFragmentManager與FragmentStatePagerAdapter和FragmentPagerAdapter的構造函數不兼容。問題?謝謝

回答

0

問題是我在後臺使用replace而不是add