大佬教程收集整理的这篇文章主要介绍了Android:按时间间隔更改图像,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
final Images@R_@R_696_11280@_9464@lized item; final ImageView bgImage=(ImageView) findViewById(R.id.imagE); ArrayList<Images@R_@R_696_11280@_9464@lized> list; control = (Controller) getApplicationContext(); list = (ArrayList<Images@R_@R_696_11280@_9464@lized>) control.Table_Images.GetData(); for(int i=0; i<list.size(); i++) { item = list.get(i); } downloader = new ImageDownloader(); downloader.download(item.imageurl(),bgImagE);
final ImageView bgImage=(ImageView) findViewById(R.id.imagE); ... new Runnable() { int @R_674_9531@eInterval = 1000; //=one second @Override public void run() { // Any code which goes here will be executed every '@R_674_9531@eInterval' // change your BACkground here bgImage.postDelayed(this,@R_674_9531@eInterval); } }.run();
您可以根据需要更改此模板,假设我想要停止此计时器,为此我必须向runnable添加一个stop方法(此stop方法同步并且不会导致计时器内部代码不一致):
Runnable myRunnable = new Runnable() { int @R_674_9531@eInterval = 1000; //=one second Boolean stop = false; public void stop() { this.stop = true; } @Override public void run() { // Any code which goes here will be executed every '@R_674_9531@eInterval' // change your BACkground here if(!stop) { bgImage.postDelayed(this,@R_674_9531@eInterval); } } }.run();
现在我可以通过myRunnable.stop()来阻止它;
编辑:
您应该迭代您的URL数组并将其中一个传递给您的下载程序.它可以通过以下代码段完成:
int arraySize = list.size(); new Runnable() { int currenTindex = 0; int @R_674_9531@eInterval = 1000; //=one second @Override public void run() { currenTindex += 1; if(currenTindex == arraySizE){ currenTindex = 0; } item = list.get(currenTindeX); downloader.download(item.imageurl(),bgImagE); bgImage.postDelayed(this,@R_674_9531@eInterval); } }.run();
以上是大佬教程为你收集整理的Android:按时间间隔更改图像全部内容,希望文章能够帮你解决Android:按时间间隔更改图像所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。