我有:
OneFragment.java (Class OneFragment extends Fragment )
TwoFragment.java (Class TwoFragment extends Fragment )
ThreeFragment.java (Class ThreeFragment extends Fragment )
FourFragment.java (Class FourFragment extends Fragment )
FiveFragment.java (Class FiveFragment extends Fragment )
以上所有内容都在一个名为“MainActivity”的活动中,上述每个项目都有1个.xml布局。
我想重启TwoFragment.java
,我该怎么做?
我创建片段的主要活动代码:
private void setupViewPager(ViewPager viewPager) {
//ino public kardam Bala hal shod
adapter.addFragment(new OneFragment(), "تماس با ما");
adapter.addFragment(new TwoFragment(), "نتایج");
adapter.addFragment(new ThreeFragment(), "ایجاد لینک");
adapter.addFragment(new FourFragment(), "تنظیمات");
adapter.addFragment(new FiveFragment(), "سوالات");
viewPager.setAdapter(adapter);
viewPager.setPageTransformer(true, new ZoomOutPageTransformer());
//viewPager.setPageTransformer(true, new DrawFromBackTransformer());
}
class ViewPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();
public ViewPagerAdapter(FragmentManager manager) {
super(manager);
}
@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
@Override
public int getCount() {
return mFragmentList.size();
}
public void addFragment(Fragment fragment, String title) {
mFragmentList.add(fragment);
mFragmentTitleList.add(title);
}private void setupViewPager(ViewPager viewPager) {
//ino public kardam Bala hal shod
adapter.addFragment(new OneFragment(), "تماس با ما");
adapter.addFragment(new TwoFragment(), "نتایج");
adapter.addFragment(new ThreeFragment(), "ایجاد لینک");
adapter.addFragment(new FourFragment(), "تنظیمات");
adapter.addFragment(new FiveFragment(), "سوالات");
viewPager.setAdapter(adapter);
viewPager.setPageTransformer(true, new ZoomOutPageTransformer());
//viewPager.setPageTransformer(true, new DrawFromBackTransformer());
}
class ViewPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();
public ViewPagerAdapter(FragmentManager manager) {
super(manager);
}
@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
@Override
public int getCount() {
return mFragmentList.size();
}
public void addFragment(Fragment fragment, String title) {
mFragmentList.add(fragment);
mFragmentTitleList.add(title);
}private void setupViewPager(ViewPager viewPager) {
//ino public kardam Bala hal shod
adapter.addFragment(new OneFragment(), "تماس با ما");
adapter.addFragment(new TwoFragment(), "نتایج");
adapter.addFragment(new ThreeFragment(), "ایجاد لینک");
adapter.addFragment(new FourFragment(), "تنظیمات");
adapter.addFragment(new FiveFragment(), "سوالات");
viewPager.setAdapter(adapter);
viewPager.setPageTransformer(true, new ZoomOutPageTransformer());
//viewPager.setPageTransformer(true, new DrawFromBackTransformer());
}
class ViewPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();
public ViewPagerAdapter(FragmentManager manager) {
super(manager);
}
@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
@Override
public int getCount() {
return mFragmentList.size();
}
public void addFragment(Fragment fragment, String title) {
mFragmentList.add(fragment);
mFragmentTitleList.add(title);
}private void setupViewPager(ViewPager viewPager) {
//ino public kardam Bala hal shod
adapter.addFragment(new OneFragment(), "تماس با ما");
adapter.addFragment(new TwoFragment(), "نتایج");
adapter.addFragment(new ThreeFragment(), "ایجاد لینک");
adapter.addFragment(new FourFragment(), "تنظیمات");
adapter.addFragment(new FiveFragment(), "سوالات");
viewPager.setAdapter(adapter);
viewPager.setPageTransformer(true, new ZoomOutPageTransformer());
//viewPager.setPageTransformer(true, new DrawFromBackTransformer());
}
class ViewPagerAdapter extends FragmentPagerAdapter {
private final List<Fragment> mFragmentList = new ArrayList<>();
private final List<String> mFragmentTitleList = new ArrayList<>();
public ViewPagerAdapter(FragmentManager manager) {
super(manager);
}
@Override
public Fragment getItem(int position) {
return mFragmentList.get(position);
}
@Override
public int getCount() {
return mFragmentList.size();
}
public void addFragment(Fragment fragment, String title) {
mFragmentList.add(fragment);
mFragmentTitleList.add(title);
}
提前致谢。