-3
我有一个应用程序,其中有一个不变的背景图像。我想在点击时随机更改此背景图片。我该怎么做?在Android中随机更改背景图像
我有一个应用程序,其中有一个不变的背景图像。我想在点击时随机更改此背景图片。我该怎么做?在Android中随机更改背景图像
int images[] = {R.drawable.image1, R.drawable.image2, R.drawable.image2};
view.setBackgroundDrawable(getResources.getDrawable(image[new Random().nextInt(images.length())]));
创建数组您绘制 设置使用图像阵列上的绘制,所以你需要一个随机索引视图的背景。
[更改按钮上的背景图片点击android应用程序开发](http://stackoverflow.com/questions/29735869/changing-background-image-on-button-click-android-app-development) – Sanoop