我用cuberto liquid pager做了一个启动屏幕(介绍性活动)。我的下一个活动应该是在船上的活动,其中有3个片段。问题是在运行代码之后,启动屏幕和入职活动的第一个片段被合并了。我试过不同的解决办法,但都没用。请阐明这个问题。
introductoryactivity.java简介
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_introductory);
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayShowHomeEnabled(false);
getSupportActionBar().hide();
h1= findViewById(R.id.houseintro);
h2= findViewById(R.id.houseintro2);
bottom= findViewById(R.id.bottom);
txt1= findViewById(R.id.atsingleplace);
txt2= findViewById(R.id.findallprop);
appname= findViewById(R.id.findmehome);
h1.animate().translationY(-2000).setDuration(1000).setStartDelay(6000);
h2.animate().translationY(2000).setDuration(1000).setStartDelay(6000);
bottom.animate().translationY(3000).setDuration(1000).setStartDelay(6000);
txt2.animate().translationY(2000).setDuration(1000).setStartDelay(6000);
txt1.animate().translationY(2000).setDuration(1000).setStartDelay(6000);
appname.animate().translationY(2000).setDuration(1000).setStartDelay(6000);
viewPager=findViewById(R.id.pager);
pagerAdapter=new ScreenSlidePagerAdapter(getSupportFragmentManager(),1);
viewPager.setAdapter(pagerAdapter);
}
private class ScreenSlidePagerAdapter extends FragmentStatePagerAdapter{
@SuppressLint("WrongConstant")
public ScreenSlidePagerAdapter(@NonNull FragmentManager fm, int i) {
super(fm, FragmentStatePagerAdapter.BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
}
@NonNull
@Override
public Fragment getItem(int position) {
switch (position){
case 0:
OnBoardingFragment1 tab1 =new OnBoardingFragment1();
return tab1;
case 1:
OnBoardingFragment2 tab2 =new OnBoardingFragment2();
return tab2;
case 2:
OnBoardingFragment3 tab3 =new OnBoardingFragment3();
return tab3;
}
return null;
}
@Override
public int getCount() {
return NUM_PAGES;
}
}
}
onboardingfragment1.java版本
public class OnBoardingFragment1 extends Fragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
ViewGroup root=(ViewGroup) inflater.inflate(R.layout.fragment_on_boarding1,container,false);
return root;
//return super.onCreateView(inflater, container, savedInstanceState);
}
}
onboardingfragment2.java版本
public class OnBoardingFragment2 extends Fragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
ViewGroup root=(ViewGroup) inflater.inflate(R.layout.fragment_on_boarding2,container,false);
return root;
//return super.onCreateView(inflater, container, savedInstanceState);
}
}
船上碎片3
public class OnBoardingFragment3 extends Fragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
ViewGroup root=(ViewGroup) inflater.inflate(R.layout.fragment_on_boarding3,container,false);
return root;
//return super.onCreateView(inflater, container, savedInstanceState);
}
}
暂无答案!
目前还没有任何答案,快来回答吧!