Exemplo n.º 1
0
 @Override
 public void onAttachFragment(Fragment fragment) {
   super.onAttachFragment(fragment);
   if (fragment.getClass() != PodcastDetailFragment.class) return;
   for (WeakReference<Fragment> frag : _savedFragments)
     if (frag.get() != null && fragment.getClass().equals(frag.get().getClass())) return;
   _savedFragments.add(new WeakReference<Fragment>(fragment));
 }
Exemplo n.º 2
0
  public void replaceFragment(Fragment fragment) {

    Log.d(Constants.LOG_TAG, " Entering Replace Fragment " + fragment.getClass().getName());

    getSlots();

    ((LandingActivity) getActivity())
        .getSupportFragmentManager()
        .beginTransaction()
        .replace(R.id.container, fragment)
        .addToBackStack(fragment.getClass().getName())
        .commit();
  }
Exemplo n.º 3
0
  private Boolean manageFragment(Fragment solicitaded) {
    if (mFragment == null) return true;
    if (solicitaded.getClass() == mFragment.getClass()) {
      return false;
    }
    /*if(solicitaded instanceof MainFragment)
    if(appState++ == 1) {
        finish();
    }else{
        return true;
    }*/

    return true;
  }
Exemplo n.º 4
0
 private void replaceFragment(Fragment fragment) {
   final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
   ft.setCustomAnimations(R.anim.fragment_fade_enter, R.anim.fragment_fade_exit);
   ft.replace(R.id.content_view, fragment, fragment.getClass().getSimpleName());
   ft.addToBackStack(null);
   ft.commit();
 }
Exemplo n.º 5
0
  public static void RecreateFragemnt(
      FragmentManager manager, String fragmentName, int containerId, String tag) {
    List<Fragment> fragments = manager.getFragments();
    FragmentTransaction transaction = manager.beginTransaction();
    boolean isexist = false;
    try {
      for (Fragment fragment : fragments) {
        transaction.hide(fragment);
        if (fragment.getClass().toString().contains(fragmentName)) {
          transaction.remove(fragment);
          Class c = Class.forName(fragmentName);
          Fragment newfragment = (Fragment) c.newInstance();
          transaction.add(containerId, newfragment, tag);
          isexist = true;
          transaction.show(newfragment);
        }
      }
      if (!isexist) {
        Class c = Class.forName(fragmentName);
        Fragment newfragment = (Fragment) c.newInstance();
        transaction.add(containerId, newfragment, tag);
        transaction.show(newfragment);
      }
      transaction.commit();
    } catch (Exception ex) {

    }
  }
Exemplo n.º 6
0
  @Override
  public void onBackPressed() {
    boolean handled = false;
    try {
      FragmentManager fm = getSupportFragmentManager();
      Fragment frag = fm.findFragmentById(R.id.fragment_content);
      if (!(frag instanceof FragUtils.BackPressedHandler)) {
        Log.d(TAG, "frag type was: " + (frag == null ? "null" : frag.getClass().getSimpleName()));
        return;
      }

      if (!frag.isVisible()) {
        Log.d(TAG, "frag was not visible!");
        return;
      }

      handled = ((FragUtils.BackPressedHandler) frag).handleBackPressed();
      //      Log.w(TAG, "handleBackPressed returned: " + handled);
    } catch (Exception e) {
      Log.e(TAG, "Could not check onBackPressed", e);
    } finally {
      if (!handled) {
        super.onBackPressed();
      }
    }
  }
Exemplo n.º 7
0
  boolean showFragment(Fragment fragment, String ftag, FragType type, int anim) {
    FragmentManager fragmentManager = MainActivity.getInstance().getSupportFragmentManager();
    if (getFragment(ftag) != null) {
      StringBuilder sb = new StringBuilder();
      sb.append("Fragment:");
      sb.append(fragment.getClass().getName());
      sb.append(" Tag:");
      sb.append(ftag);
      sb.append(" has exist!");
      return false;
    }

    FragmentTransaction transaction = fragmentManager.beginTransaction();

    if (anim != 0) transaction.setCustomAnimations(anim, 0);

    transaction.add(R.id.main_frame, fragment, ftag);

    // 只保留当前层和其下一�?
    if (fragmentStack.size() > 1)
      transaction.hide(fragmentStack.get(fragmentStack.size() - 2).second);
    transaction.setTransition(FragmentTransaction.TRANSIT_NONE);
    transaction.addToBackStack(ftag);
    pushFragment(fragment, ftag);
    transaction.commitAllowingStateLoss();
    return true;
  }
 /**
  * This method determines whether the current displaying fragment is the target expected. If not,
  * the current fragment will be replaced by the target fragment.
  *
  * @param currentFragment the displaying fragment of the activity
  * @param targetFragment the target fragment to be displayed
  * @param isNewFragment state whether a new fragment should be displayed
  */
 private void displayFragment(
     Fragment currentFragment, Fragment targetFragment, boolean isNewFragment) {
   if (currentFragment == null) {
     rFragmentManager
         .beginTransaction()
         .add(R.id.register_fragment_container, targetFragment)
         .commit();
     rFragmentManager.executePendingTransactions();
   } else if (!(currentFragment.getClass().equals(targetFragment.getClass())) || isNewFragment) {
     rFragmentManager
         .beginTransaction()
         .replace(R.id.register_fragment_container, targetFragment)
         .commit();
     rFragmentManager.executePendingTransactions();
   }
 }
 @Override
 public Object instantiateItem(ViewGroup container, int position) {
   Fragment fragment;
   // If we already have this item instantiated, there is nothing
   // to do.  This can happen when we are restoring the entire pager
   // from its saved state, where the fragment manager has already
   // taken care of restoring the fragments we previously had instantiated.
   fragment = mFragments.get(position);
   if (fragment != null) {
     return fragment;
   }
   if (mCurTransaction == null) {
     mCurTransaction = mFragmentManager.beginTransaction();
   }
   FragmentState fs = mFragmentStates.get(position);
   if (fs != null) {
     FragmentManager fragmentManager = getFragmentActivity().getSupportFragmentManager();
     if (getParentFragment() != null) {
       fragmentManager = getParentFragment().getChildFragmentManager();
     }
     // Fix Can't change tag of fragment Error
     // http://stackoverflow.com/questions/24355838/cant-change-tag-of-fragment-error-trying-to-use-a-pageradapter-for-switching
     if ((fs.mTag != null && fs.mTag.equals(mFragmentTags.get(position)))
         || (fs.mTag == null && mFragmentTags.get(position) == null)) {
       fragment =
           fs.instantiate(
               FragmentUtils.getFragmentHostCallback(fragmentManager),
               getParentFragment(),
               FragmentUtils.getFragmentManagerNonConfig(fragmentManager));
       // Fix bug
       // http://stackoverflow.com/questions/11381470/classnotfoundexception-when-unmarshalling-android-support-v4-view-viewpagersav
       if (fragment.mSavedFragmentState != null) {
         fragment.mSavedFragmentState.setClassLoader(fragment.getClass().getClassLoader());
       }
     } else {
       Log.e(
           TAG,
           String.format(
               "Fragment tag isn't equal! Origin: %s %s", fs.mTag, mFragmentTags.get(position)));
       mFragmentStates.set(position, null);
     }
   }
   if (fragment == null) {
     fragment =
         Fragment.instantiate(
             getFragmentActivity(),
             mFragmentClassNames.get(position),
             mFragmentArgs.get(position));
   }
   if (DEBUG) {
     Log.v(TAG, "Adding item #" + position + ": f=" + fragment);
   }
   fragment.setMenuVisibility(false);
   fragment.setUserVisibleHint(false);
   mFragments.set(position, fragment);
   mFragmentStates.set(position, null);
   mCurTransaction.add(container.getId(), fragment, mFragmentTags.get(position));
   return fragment;
 }
Exemplo n.º 10
0
 /** 开启新的Fragment */
 private void open(Fragment fragment) {
   final String tag = fragment.getClass().toString();
   getActivity()
       .getSupportFragmentManager()
       .beginTransaction()
       .addToBackStack(tag)
       .replace(R.id.main_content, fragment, tag)
       .commit();
 }
  @Override
  public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
      Bundle bundle = (Bundle) state;
      bundle.setClassLoader(loader);
      ArrayList<FragmentState> fs = bundle.getParcelableArrayList("states_fragment");
      ArrayList<Bundle> args = bundle.getParcelableArrayList("arg_fragment");
      ArrayList<String> tags = bundle.getStringArrayList("tag_fragment");
      ArrayList<String> classNames = bundle.getStringArrayList("classname_fragment");

      mFragments.clear();
      mFragmentStates.clear();
      mFragmentTags.clear();
      mFragmentClassNames.clear();
      mFragmentArgs.clear();
      if (fs != null) {
        for (int i = 0; i < fs.size(); i++) {
          FragmentState fragmentState = fs.get(i);
          mFragmentStates.add(fragmentState);
          if (fragmentState != null) {
            mFragmentArgs.add(fragmentState.mArguments);
            mFragmentTags.add(fragmentState.mTag);
            mFragmentClassNames.add(fragmentState.mClassName);
          } else {
            mFragmentArgs.add(args.get(i));
            mFragmentTags.add(tags.get(i));
            mFragmentClassNames.add(classNames.get(i));
          }
          mFragments.add(null);
        }
      }
      Iterable<String> keys = bundle.keySet();
      for (String key : keys) {
        if (key.startsWith("f")) {
          int index = Integer.parseInt(key.substring(1));
          Fragment f = null;
          try {
            f = mFragmentManager.getFragment(bundle, key);
          } catch (Throwable ex) {
            ex.printStackTrace();
          }
          if (f != null) {
            f.setMenuVisibility(false);
            mFragments.set(index, f);
            mFragmentArgs.set(index, f.mArguments);
            mFragmentTags.set(index, f.mTag);
            mFragmentClassNames.set(index, f.getClass().getName());
          } else {
            Log.w(TAG, "Bad fragment at key " + key);
          }
        }
      }
      // If restore will change
      notifyDataSetChanged();
    }
  }
Exemplo n.º 12
0
 public void onTabReselected(Tab tab, FragmentTransaction ft) {
   if (fragment.getClass().toString().equalsIgnoreCase(EmergencyFragment.class.toString())) {
     FragmentManager fm = getSupportFragmentManager();
     DialogoFinder finder = new DialogoFinder();
     Log.i("TabListener", "Antes del show");
     finder.show(fm, "dialog1");
     Log.i("TabListener", "Despues del show");
     return;
   }
 }
Exemplo n.º 13
0
 /** Checks if allocated fragment is of the required type and then returns it or returns null */
 private Fragment checkFragmentInstance(int id, Object instanceClass) {
   Fragment result = null;
   if (mFragmentManager != null) {
     Fragment fragment = mFragmentManager.findFragmentById(id);
     if (instanceClass.equals(fragment.getClass())) {
       result = fragment;
     }
   }
   return result;
 }
  @Test
  public void getFragment_whenBundleSavedByShadowFragmentActivity_shouldGetFragmentByTagFromBundle()
      throws Exception {
    manager.addFragment(CONTAINER_VIEW_ID, "fragment tag", fragment, true);

    Bundle outState = new Bundle();
    shadowOf(activity).onSaveInstanceState(outState);

    Fragment retrievedFragment = manager.getFragment(outState, "fragment tag");
    assertEquals(TestFragment.class, retrievedFragment.getClass());
  }
Exemplo n.º 15
0
  @Override
  public void render(Fragment fragment) {
    getSupportFragmentManager()
        .beginTransaction()
        .addToBackStack(MainActivity.class.getSimpleName())
        .replace(R.id.main_frame, fragment, fragment.getClass().getSimpleName())
        .commit();

    findViewById(R.id.main_frame).bringToFront();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
  }
Exemplo n.º 16
0
 public void onTabSelected(Tab tab, FragmentTransaction ft) {
   Log.i("TabListener", "Es un tab select");
   if (fragment.getClass().toString().equalsIgnoreCase(EmergencyFragment.class.toString())) {
     FragmentManager fm = getSupportFragmentManager();
     DialogoFinder finder = new DialogoFinder();
     finder.show(fm, "dialog1");
     return;
   }
   selected = fragment;
   ft.replace(android.R.id.content, fragment, tag);
 }
Exemplo n.º 17
0
 public FragmentState(Fragment paramFragment) {
   this.mClassName = paramFragment.getClass().getName();
   this.mIndex = paramFragment.mIndex;
   this.mFromLayout = paramFragment.mFromLayout;
   this.mFragmentId = paramFragment.mFragmentId;
   this.mContainerId = paramFragment.mContainerId;
   this.mTag = paramFragment.mTag;
   this.mRetainInstance = paramFragment.mRetainInstance;
   this.mDetached = paramFragment.mDetached;
   this.mArguments = paramFragment.mArguments;
 }
  @Override
  public WebViewBridge loadWebViewBridge(Fragment fragment, View inflatedView) {
    Class<?> clazz = fragment.getClass();
    LayoutConfig config = createLayoutConfig(clazz);

    WebViewBridge webViewBridge =
        (WebViewBridge) inflatedView.findViewById(config.getWebViewBridgeId());
    webViewBridge.setDomainConfig(createDomainConfig(clazz));
    webViewBridge.setNoPause(hasNoPause(clazz));

    return webViewBridge;
  }
Exemplo n.º 19
0
 private Boolean isFragmentAdded(String tag) {
   FragmentManager manager = getSupportFragmentManager();
   List<Fragment> fragmentList = manager.getFragments();
   if (fragmentList != null) {
     for (int i = fragmentList.size() - 1; i > -1; i--) {
       Fragment fragment = fragmentList.get(i);
       if (fragment != null && fragment.getClass().getName().equals(tag) && !fragment.isRemoving())
         return true;
     }
   }
   return false;
 }
Exemplo n.º 20
0
  protected void loadFragement(Fragment newFragment) {
    if (actualFragment == null || !actualFragment.getClass().equals(newFragment.getClass())) {

      ActionBar actionBar = getSupportActionBar();
      actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE);
      if (newFragment instanceof MainFragment) actionBar.setIcon(R.mipmap.ic_launcher);
      else if (newFragment instanceof ExperimentalFragment)
        actionBar.setIcon(R.mipmap.fragement_experimental);
      else if (newFragment instanceof TechnicalFragment)
        actionBar.setIcon(R.mipmap.fragement_technical);

      actualFragment = newFragment;
      // Create fragment and give it an argument specifying the article it should show
      FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
      // Replace whatever is in the fragment_container view with this fragment,
      // and add the transaction to the back stack so the user can navigate back
      transaction.replace(R.id.main, newFragment);
      // transaction.addToBackStack(null);
      // Commit the transaction
      transaction.commit();
    }
  }
Exemplo n.º 21
0
  private void advanceWizardSubFragment(Fragment fragment) {
    idx = 0;
    for (Fragment f : subFragments) {
      if (fragment.getClass().getSimpleName().equals(f.getClass().getSimpleName())) {
        ((WizardListener) subFragments.get(0)).onSubFragmentInitialized();
        break;
      }
      idx++;
    }

    Log.d(LOG, "subfragments size: " + subFragments.size());

    if (idx == 0) {
      subFragmentNext.setClickable(true);
    } else if (idx == subFragments.size() - 1) {
      subFragmentNext.setClickable(false);
    }

    try {
      ((WizardListener) subFragments.get(idx - 1)).onSubFragmentCompleted();
    } catch (ArrayIndexOutOfBoundsException e) {
    }

    FragmentTransaction ft = ((WizardListener) a).returnFragmentManager().beginTransaction();
    ft.replace(R.id.wizard_sub_fragments_root, fragment);
    ft.addToBackStack(null);
    ft.commit();

    for (int i = 0; i < subFragmentProgress.getChildCount(); i++) {
      int dot = R.drawable.progress_inactive;
      if (i == idx) {
        dot = R.drawable.progress_active;
      }

      ((ImageView) subFragmentProgress.getChildAt(i))
          .setImageDrawable(getResources().getDrawable(dot));
    }
  }
Exemplo n.º 22
0
  public void initLayout() {
    pager = new TabPager(getSupportFragmentManager());

    tabHost = (TabHost) findViewById(android.R.id.tabhost);
    tabHost.setup();

    tabHost.setOnTabChangedListener(pager);
    viewPager.setAdapter(pager);
    viewPager.setOnPageChangeListener(pager);
    viewPager.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            return true;
          }
        });

    TabHost.TabSpec tabSpec = null;

    @SuppressWarnings("unused")
    View indicator = null;

    int i = 1;

    for (Fragment f : fragments) {
      tabSpec =
          tabHost
              .newTabSpec(f.getClass().getSimpleName())
              .setIndicator(indicator = new Indicator(String.valueOf(i), this).tab)
              .setContent(
                  new TabHost.TabContentFactory() {

                    @Override
                    public View createTabContent(String tag) {
                      View view = new View(WizardActivity.this);
                      view.setMinimumHeight(0);
                      view.setMinimumWidth(0);
                      return view;
                    }
                  });
      tabHost.addTab(tabSpec);
      i++;
    }

    if (getIntent().hasExtra(Codes.Extras.CHANGE_LOCALE)) {
      getIntent().removeExtra(Codes.Extras.CHANGE_LOCALE);
      viewPager.setCurrentItem(1);
    }
  }
Exemplo n.º 23
0
  public static Fragment GetFragemnt(FragmentManager manager, String fragmentName) {
    List<Fragment> fragments = manager.getFragments();
    try {
      for (Fragment fragment : fragments) {

        if (fragment.getClass().toString().contains(fragmentName)) {
          return fragment;
        }
      }
    } catch (Exception ex) {

    }
    return null;
  }
Exemplo n.º 24
0
  @Override
  public void onBackPressed() {

    Fragment details = getSupportFragmentManager().findFragmentById(R.id.detailPane);
    Log.w(Constants.TAG, "instanceof: " + details.getClass());
    if (details instanceof TagDetailFragment) {
      supportFinishAfterTransition();
      super.onBackPressed();
    } else {
      getSupportFragmentManager().popBackStack();
      setActionBarInfo(collected.getNiceName());
      // don't call super here
    }
  }
Exemplo n.º 25
0
 private void showFragment(String tag, FragmentTransaction transaction) {
   FragmentManager manager = getSupportFragmentManager();
   List<Fragment> fragmentList = manager.getFragments();
   if (fragmentList != null)
     for (Fragment fragment : fragmentList) {
       if (fragment != null) {
         if (fragment.getClass().getName().equals(tag)) {
           transaction.show(fragment);
         } else {
           transaction.hide(fragment);
         }
       }
     }
   transaction.commit();
 }
Exemplo n.º 26
0
  private void updateSubmenuAndTitle(Fragment f) {
    String fragClassName = f.getClass().getSimpleName();
    TextView title = (TextView) findViewById(R.id.nav_bar_title);

    if (fragClassName.equals(FRAGMENT_PROFILE_OVERVIEW)
        || fragClassName.equals(FRAGMENT_PROFILE_CONTACT_AND_EMPLOYER)
        || fragClassName.equals(FRAGMENT_PROFILE_DEPENDANTS_AND_BENEFICIARIES)) {
      submenu_bar.setVisibility(View.VISIBLE);
    } else {
      submenu_bar.setVisibility(View.GONE);
    }

    switch (fragClassName) {
      case FRAGMENT_PROFILE_OVERVIEW:
        title.setText(PROFILE);
        setSubmenuTitle(submenu_profile[0]);
        setSubmenuOptions(submenu_profile);
        break;
      case FRAGMENT_PROFILE_CONTACT_AND_EMPLOYER:
        title.setText(PROFILE);
        setSubmenuTitle(submenu_profile[1]);
        setSubmenuOptions(submenu_profile);
        break;
      case FRAGMENT_PROFILE_DEPENDANTS_AND_BENEFICIARIES:
        title.setText(PROFILE);
        setSubmenuTitle(submenu_profile[2]);
        setSubmenuOptions(submenu_profile);
        break;
      case FRAGMENT_CLAIM_HISTORY:
        title.setText(CLAIMS_HISTORY);
        break;
      case FRAGMENT_BENEFIT_COVERAGE:
        title.setText(BENEFIT_COVERAGE);
        break;
      case FRAGMENT_DOCUMENTS:
        title.setText(DOCUMENTS);
        break;
      case FRAGMENT_PROFILE_EDIT_CONTACT_INFO:
        break;

      default:
        title.setText(WELCOME);
        break;
    }
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);
    log("onCreate()");

    if (savedInstanceState != null) {
      log("onCreate() - after rotation");

      final Bundle bundle = savedInstanceState.getBundle(SAVED_TARGET_FRAGMENT);
      final Fragment targetFragment =
          getFragmentManager().getFragment(bundle, SAVED_TARGET_FRAGMENT);

      log(
          "onCreate() - restored from bundle",
          targetFragment != null ? targetFragment.getClass().getName() : "null");
    }
  }
Exemplo n.º 28
0
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    ImageView icon = (ImageView) findViewById(R.id.node_icon);
    switch (item.getItemId()) {
      case android.R.id.home:
        Fragment details = getSupportFragmentManager().findFragmentById(R.id.detailPane);
        Log.w(Constants.TAG, "instanceof: " + details.getClass());
        if (details instanceof TagDetailFragment) supportFinishAfterTransition();
        else {
          getSupportFragmentManager().popBackStack();
          setActionBarInfo(collected.getNiceName());
        }
        return true;
      case R.id.Opzioni:
        Intent settingsActivity = new Intent(this, PreferencesActivity.class);
        startActivity(settingsActivity);
        final Intent preferencesActivity =
            new Intent(this.getBaseContext(), PreferencesActivity.class);
        // evita doppie aperture per via delle sotto-schermate
        preferencesActivity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(preferencesActivity);
        return true;
      case R.id.scegliconaTag:
        AlertDialog.Builder alert2 =
            AlertDialogHelper.chooseIconDialog(this, icon, null, db, collected);
        alert2.show();
        return true;
      case R.id.rinominaTag:
        AlertDialog.Builder alert =
            AlertDialogHelper.renameSoulissObjectDialog(
                this, actionTitleTextView, null, db, collected);
        alert.show();
        return true;
      case R.id.scegliImmagineTag:
        Intent intent =
            new Intent(
                Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
        startActivityForResult(intent, collected.getTagId().intValue());
        return true;
    }

    return super.onOptionsItemSelected(item);
  }
 @Override
 public boolean onOptionsItemSelected(com.actionbarsherlock.view.MenuItem item) {
   Fragment currentTab = getChildFragmentManager().findFragmentById(R.id.content);
   Log.d(TAG, "Current fragment: " + currentTab.getClass().toString());
   switch (item.getItemId()) {
     case R.id.menu_manual_add:
       if (currentTab instanceof INovelListHelper) ((INovelListHelper) currentTab).manualAdd();
       return true;
     case R.id.menu_download_all_info:
       if (currentTab instanceof INovelListHelper)
         ((INovelListHelper) currentTab).downloadAllNovelInfo();
       return true;
     case R.id.menu_refresh_novel_list:
       if (currentTab instanceof INovelListHelper) ((INovelListHelper) currentTab).refreshList();
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
Exemplo n.º 30
0
  @Override
  public Object instantiateItem(ViewGroup container, int position) {
    Fragment fragment = fragments.get(position);
    if (!fragment.isAdded()) { // 如果fragment还没有added
      FragmentTransaction ft = fragmentManager.beginTransaction();
      ft.add(fragment, fragment.getClass().getSimpleName());
      ft.commit();
      /**
       * 在用FragmentTransaction.commit()方法提交FragmentTransaction对象后 会在进程的主线程中,用异步的方式来执行。
       * 如果想要立即执行这个等待中的操作,就要调用这个方法(只能在主线程中调用)。 要注意的是,所有的回调和相关的行为都会在这个调用中被执行完成,因此要仔细确认这个方法的调用位置。
       */
      fragmentManager.executePendingTransactions();
    }

    if (fragment.getView().getParent() == null) {
      container.addView(fragment.getView()); // 为viewpager增加布局
    }

    return fragment.getView();
  }