简体   繁体   English

图像在Android中连续播放幻灯片

[英]slideshow of images continously in android

I want to display images continuously with 5 seconds gap using imageview in android. 我想在Android中使用imageview以5秒的间隔连续显示图像。

I have tried following code 我尝试了以下代码

String[] Img_data = { MediaStore.Images.Media.DATA };

   Cursor imgcursor = this.managedQuery(
                MediaStore.Images.Media.EXTERNAL_CONTENT_URI,    Img_data,null,null, null); 

         if(imgcursor!=null && img_cursor.getCount()>0){

           while(!imgcursor.isAfterLast()){

            imgcursor.moveToFirst();

              String filepath = cursor.getString(columnIndex);

              imageview.setImageUri(Uri.parse(filepath);
              imgcursor.moveToNext();
           }

         }

Please send me the appropriate answer for this question. 请给我相应的答案。

Use Handler for this as below :- 为此使用处理程序:

Handler mHandler = new Handler();
mHandler.postDelayed(mRunnable, 2000);

final Runnable mRunnable = new Runnable()
{
    @Override
    public void run()
    {

            Utility.getInstance(getActivity()).displayImage(mImageUrlsTop.get(mCounterTop++), mImageViewTop, mProgressBarTop);
            mHandler.postDelayed(mRunnable, 2000);                          
    }
};

Here displayImage is the my function to display image for provided URL and Imageview & mImageUrlsTop is the arraylist of ImageUrl's. 在这里,displayImage是我的功能,用于显示提供的URL和Imageview的图像,而mImageUrlsTop是ImageUrl的数组列表。

try this code 试试这个代码

 private Runnable updateImageThread = new Runnable() {

            public void run() {

                timeInMilliseconds = SystemClock.uptimeMillis() - startTime1;

                updatedTime = timeSwapBuff + timeInMilliseconds;

                int secs = (int) (updatedTime / 1000);
                int mins = secs / 60;
                secs = secs % 60;
                int milliseconds = (int) (updatedTime % 5000);
    // set images to imageview  here as per your need

                customHandler.postDelayed(this, 0);
            }

        };


// call this thread like this
private Handler customHandler = new Handler();
long timeInMilliseconds = 0L;
long updatedTime = 0L;
customHandler.postDelayed(updateImageThread, 0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用按钮单击 Android 连续更改图像 - Changing Images continously with button click Android 使用 android 中的图像创建 animation 序列(幻灯片) - Creating an animation sequence with images in android (SlideShow) android ViewFlipper - 带有异步图像加载的图像幻灯片 - android ViewFlipper - slideshow of images with async image loading 如何在 Android Studio 中创建文字和图像的幻灯片? - How do I create a slideshow of words and images in Android Studio? 如何在自定义幻灯片中以android显示图像的应用程序屏幕? - how to record app's screen in android showing images in in custom slideshow? 如何以编程方式将图像的幻灯片设置为android主屏幕(墙纸)? - How to set a slideshow of images as android home screen(wallpaper) programmatically? 安卓中的幻灯片 - Slideshow in android 我正在不断地从 Android 应用程序向 s3 上传图像,有些已成功上传,但有些图像上传失败 - I am Continously uploading images to s3 from Android app some are successfully uploaded but some images are getting failed to upload 在Android中连续比较两次 - Compare two time continously in android Android Register BroadcastReceiver可以连续运行 - Android Register BroadcastReceiver to run continously
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM