我有一个 SplashScreen,它是一个 ViewPager,我需要在点击时将登录片段添加到它。
这是我的寻呼机适配器:
public class SplashSAdapter extends PagerAdapter {
Context ssContext;
Activity _activity;
private int[] ssImages = new int[] { R.drawable.splashscreen1,R.drawable.splashscreen2, R.drawable.splashscreen3 };
public SplashSAdapter(Context ssContext, Activity activity) {
this.ssContext = ssContext;
this._activity = activity;
}
@Override
public int getCount() {
return ssImages.length;
}
@Override
public boolean isViewFromObject(View ssView, Object ssObject) {
return ssView == ((ImageView) ssObject);
}
@Override
public Object instantiateItem(ViewGroup ssContainer, int ssPosition) {
ImageView ssImageView = new ImageView(ssContext);
ssImageView.setScaleType(ImageView.ScaleType.FIT_XY);
ssImageView.setImageResource(ssImages[ssPosition]);
((ViewPager) ssContainer).addView(ssImageView, 0);
ssImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
onClickSplashScreen();
}
});
return ssImageView;
}
@Override
public void destroyItem(ViewGroup ssContainer, int ssPosition,
Object ssObject) {
((ViewPager) ssContainer).removeView((ImageView) ssObject);
}
public void onClickSplashScreen(){
}
那么,onClickSplashScreen,如何在其中添加 Fragment?