Android背景问题
Android开发中,我现在在写一个类似win8的假界面,当作练习,我想实现整个桌面屏幕背景图片每隔一段时间就自动切换一张,我现在的代码是这样的,但实现不了,请各位大神指教。/*
* 背景切换类
*/
public class ChangeBackgroundThread extends Thread{
@Override
public void run() {
// TODO Auto-generated method stub
super.run();
int i=0;
do{
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println("----> 切换");
main_linear.setBackgroundDrawable
(getResources().getDrawable(BackGroundDrawable.slideImage[i]));
i++;
if(i>BackGroundDrawable.slideImage.length){
i=0;
}
}while(i<=BackGroundDrawable.slideImage.length&& mclockThread.interrupted()==false);
}
}
public class BackGroundDrawable {
public static int slideImage[]={
R.drawable.main_background,
R.drawable.backround1,
R.drawable.background2,
R.drawable.background3,
R.drawable.background4,
R.drawable.background5,
R.drawable.background6,
R.drawable.background7,
R.drawable.background8,
R.drawable.background9,
R.drawable.background10,
R.drawable.background12,
R.drawable.background13,
R.drawable.background16,
R.drawable.background17,
R.drawable.background18
};
}
为什么会实现不了呢,调试的时候,根本就执行不了main_linear.setBackgroundDrawable
(getResources().getDrawable(BackGroundDrawable.slideImage[i]));这句