您好我正在尝试创建位图壁纸。但此位图每 10 秒更改一次。我怎样才能做到这一点?
这是我尝试过的:
// I have declared
int[] images = {R.drawable.donna, R.drawable.donna1, R.drawable.marian,
R.drawable.marian1, R.drawable.marian};
Handler mHandler = new Handler();
ImageView imgView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
imgView = (ImageView) findViewById(R.id.imageView1);
new Thread(new Runnable() {
public void run() {
// TODO Auto-generated method stub
while (true) {
try {
Thread.sleep(10000);
mHandler.post(new Runnable() {
public void run() {
// TODO Auto-generated method stub
// Write your code here to update the UI.
Random ran = new Random();
imgView.setImageResource(images[ran.nextInt(images.length)]);
}
});
} catch (Exception e) {
// TODO: handle exception
}
}
}
}).start();
但我的问题是如何集成将其设置为墙纸的功能/方法?
任何帮助都非常感谢。谢谢。