我正在尝试在每个视图页面中显示延迟20秒的文本视图。视图页面还显示1分钟delay.means,在每个视图页面中我想要显示三个文本视图,在下一页面上它将显示另外三个文本。 请帮帮我。
private int[] ImageIds={R.drawable.image_asana,R.drawable.image_a,R.drawable.image_c,R.drawable.image_d,
R.drawable.image_e,R.drawable.end_image};
public static ScreenSlideFragment create(int PageNumber){
ScreenSlideFragment fragment=new ScreenSlideFragment();
Bundle args=new Bundle();
args.putInt(ARG_PAGE, PageNumber);
fragment.setArguments(args);
return fragment;
}
public ScreenSlideFragment(){
}
@Override
public void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
mPageNumber=getArguments().getInt(ARG_PAGE);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final ViewGroup rootView=(ViewGroup)inflater.inflate(R.layout.fragment_screenslide_page, container, false);
((ImageView)rootView.findViewById(R.id.image3)).setImageResource(ImageIds[mPageNumber]);
if (mPageNumber==ImageIds.length) {
handler.removeCallbacks(null);
}
final Runnable textUpdtae = new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
((TextView) rootView.findViewById(R.id.imagetextview)).setText(ImageTextIds[count++]);
}
};
newTimer = new Timer();
newTimer.schedule(new TimerTask() {
@Override
public void run() {
// TODO Auto-generated method stub
handler.post(textUpdtae);
}
}, 0, 5000);
return rootView;
}
答案 0 :(得分:0)
您可以尝试将layoutanimation设置为viewpager对象。此动画将应用于视图寻呼机包含的每个视图。
AnimationSet set = new AnimationSet(true);
Animation animation = new AlphaAnimation(0.0f, 1.0f);
animation.setDuration(500);
set.addAnimation(animation);
animation = new TranslateAnimation(
Animation.RELATIVE_TO_SELF, 50.0f,Animation.RELATIVE_TO_SELF, 0.0f,
Animation.RELATIVE_TO_SELF, 0.0f,Animation.RELATIVE_TO_SELF, 0.0f
);
animation.setDuration(1000);
set.addAnimation(animation);
LayoutAnimationController controller = new LayoutAnimationController(set, 0.5f);
<ViewPager>.setLayoutAnimation(controller);