android - android中的图像幻灯片放映

标签 android json image

我想在 android 中将图像显示为幻灯片放映。该图像将以 json 数据格式来自服务器。你能告诉我如何在将显示图像的图像 slider 中传递这些图像吗?来自服务器的 json 图像数量,它是完全动态的,一组图像...

最佳答案

最初您需要做的是计算来自 json 的图像数量。当您获得所有图像后,您可以使用水平页面将其显示给用户。它有助于像这样在每次滑动中更改图像link .否则你可以使用两个框架并可以设置两个动画并像 slider 一样显示它。我认为这段代码会对你有所帮助。

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;
            }

关于android - android中的图像幻灯片放映,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10479717/

相关文章:

android - 使用 Holo 父主题从 Theme.Light 继承 editText

java - 初始化非 null 的 Activity

json - 使用 Swift Decodable 进行动态(但称为另一个键值)JSON 解码

java - 以编程方式更改联系人图片

javascript - React 将图像 src 设置为动态路径

Android - 动态添加 fragment

php - 使用volley php发布数据

javascript - 使用 window.open(<url>,'_self) 时收到警告资源解释为文档但使用 MIME 类型 application/octet-stream 传输

javascript - 是否有标准库或函数可以从 JSON 解析字符串

python - PIL 将 png 像素导入为单个值而不是 3 个值向量