@Override
 public void onPageSelected(int index) {
   // ViewPager页面被选中的回调
   BaseFragment fragment = FragmentFactory.createFragment(index);
   // 当页面被选中 再显示要加载的页面....防止ViewPager提前加载(ViewPager一般加载三个,自己,左一个,右一个)
   fragment.show(); // 调用show方法加载pager里面的数据
 }
Beispiel #2
0
  @Override
  public void onNavigationDrawerItemSelected(int position) {
    android.app.Fragment fragment;
    // update the main content by replacing fragments
    switch (position) {
      case 0:
        fragment = FragmentFactory.newInstance(position);
        addFragment(fragment, Consts.LOCATION_FRAGMENT);
        break;
      case 1:
        fragment = FragmentFactory.newInstance(position);
        addFragment(fragment, Consts.LOCATION_FRAGMENT);
        break;

      default:
        Intent intent = new Intent(this, RestaurantViewPager.class);
        startActivity(intent);
        break;
    }
  }
  public static List<AnalyteSettings> createAnalyteSettings() {
    Scanner scan = new Scanner(System.in);
    List<AnalyteSettings> analyteSettings = new ArrayList();
    AnalyteSettings analyte = new AnalyteSettings();
    GlycanSettings gSettings = new GlycanSettings();
    gSettings.setAllowInnerFragments(false);
    gSettings.setPerDerivatisationType(getPerDerivatisationType());
    System.out.println("Set the max number of cleaveges: ");
    String maxClvg = scan.nextLine();
    gSettings.setMaxNumOfCleavages(Integer.parseInt(maxClvg));
    System.out.println("Set the max number of Cross Ring cleaveges: ");
    String maxCRClvg = scan.nextLine();
    gSettings.setMaxNumOfCrossRingCleavages(Integer.parseInt(maxCRClvg));
    gSettings.setGlycanFragments(FragmentFactory.createFragments());
    gSettings.setReducingEnd(ReducingEndFactory.createReducingEnd());

    analyte.setGlycanSettings(gSettings);
    analyteSettings.add(analyte);
    return analyteSettings;
  }
 @Override
 public Fragment getItem(int position) {
   return FragmentFactory.createFragment(position);
 }