我想在android中以幻灯片的形式显示图像。这些图像将以json数据格式从服务器传来。您能告诉我如何在显示图像的图像滑块中传递这些图像吗?json中来自服务器的多张图片,它是完全动态的,一组图片…
发布于 2012-05-07 17:44:24
最初,你需要做的就是对来自json.As的图像进行计数,你可以得到所有的图像,你可以使用horizondal pages.It帮助改变每次滑动中的图像,就像在这个link .Otherwise中,你可以使用两个帧,可以设置两个动画,并像幻灯片一样显示它。我认为这段代码会对你有所帮助。
if (imagesetflag == true) {
Right_to_left_in = AnimationUtils.loadAnimation(this,
R.anim.right_to_left_in);
Right_to_left_out = AnimationUtils.loadAnimation(this,
R.anim.right_to_left_out);
left_to_Right_in = AnimationUtils.loadAnimation(this,
R.anim.left_to_right_in);
Left_to_Right_out = AnimationUtils.loadAnimation(this,
R.anim.left_to_right_out);
frame1.setImageBitmapReset(decryptedimage, 0, true);
TVpagenum.setText("Page no:" + Currentpage + "/"
+ countOfPages);
frame1.bringToFront();
frame1.setVisibility(View.VISIBLE);
frame2.setVisibility(View.INVISIBLE);
frame1.setAnimation(Right_to_left_in);
frame2.setAnimation(Right_to_left_out);
imagesetflag = false;
} else {
Right_to_left_in = AnimationUtils.loadAnimation(this,
R.anim.right_to_left_in);
Right_to_left_out = AnimationUtils.loadAnimation(this,
R.anim.right_to_left_out);
left_to_Right_in = AnimationUtils.loadAnimation(this,
R.anim.left_to_right_in);
Left_to_Right_out = AnimationUtils.loadAnimation(this,
R.anim.left_to_right_out);
frame2.setImageBitmapReset(decryptedimage, 0, true);
TVpagenum.setText("Page no:" + Currentpage + "/"
+ countOfPages);
frame2.bringToFront();
frame2.setVisibility(View.VISIBLE);
frame1.setVisibility(View.INVISIBLE);
frame2.setAnimation(Right_to_left_in);
frame1.setAnimation(Right_to_left_out);
imagesetflag = true;
}发布于 2012-05-07 17:41:08
您应该解析即将到来的Json数据并获得图像urls。有了这些数据,您可以使用ViewPager,并在其适配器中执行asyncTask以在ViewPager的项目布局中显示图像。
或者,您可以将ViewFlipper与动画(如淡入、淡出)一起用于您的滑块。逻辑应该是相同的
https://stackoverflow.com/questions/10479717
复制相似问题