源码

首页 » 归档 » 源码 » android – 如何在一段时间后更改imageView上…

android – 如何在一段时间后更改imageView上…


我有一个问题,我想在Android上的ImageView上粘贴图像,并且在一段时间后定期更改图像.表示ImageView中显示的逐个图像.我在Java的帮助下这样做但是我遇到了一些问题,即Thread没有附加什么.请查看下面给出的代码并告诉我确切的错误以及如何删除该错误或给我一些不同的方法来做到这一点.

package com.ex.thread;

import com.ex.thread.R;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.widget.ImageView;

public class thread extends Activity implements Runnable{
/** Called when the activity is first created. */
public static Integer[] mThumbIds = {

   R.drawable.al1,R.drawable.al2,R.drawable.al3,R.drawable.al4,

};
Thread th;
ImageView iv;
public void run()
{
    for(int i=0;i<3;i++)
    {
        iv.setImageResource(mThumbIds[i]);
        System.out.println("Sanat Pandey");
        try{
            Thread.sleep(3000);
        }catch(Exception e)
        {
            System.out.println(e);
        }
    }
}
public void create()
{
    Thread th = new Thread(new thread());
    th.start();
    try{
        Thread.sleep(3000);
    }catch(Exception e)
    {
        System.out.println(e);
    }
}

@Override
public void onCreate(Bundle savedInstace)
{
    super.onCreate(savedInstace);
    setContentView(R.layout.main);
    create();
}
}
(0)

本文由 投稿者 创作,文章地址:https://blog.isoyu.com/archives/android-ruhezaiyiduanshijianhougenggaiimageviewshang.html
采用知识共享署名4.0 国际许可协议进行许可。除注明转载/出处外,均为本站原创或翻译,转载前请务必署名。最后编辑时间为:9 月 19, 2019 at 12:39 下午

热评文章