我有一个包含10个ImageView的布局。我已经给它们顺序编号,如下所示:
android:id="@+id/pb1"
android:id="@+id/pb2"
现在,我想动态地更改背景。
int totalPoi = listOfPOI.size();
int currentPoi = (j/totalPoi)*10;
for (i=1;i<=currentPoi;i++) {
imageview.setBackgroundResource(R.drawable.progressgreen);
}
现在,在for循环内部,我想动态设置图像视图的背景。即,如果currentpoi值为3,则应更改3个图像视图的背景。无论for循环迭代多少次,都应更改相应数量的图像视图的背景。希望问题现在清楚了。
注意:我只有一个名为progressgreen的图像,需要设置到10个图像视图中。