以下是定製的圓形圖像列表。需要通過循環動態分配一個值。通過循環動態指定值 - Android - 以編程方式由java
RoundedImageView img23 = (RoundedImageView) findViewById(R.id.avatar23);
img23.setImageResource(R.mipmap.avatars_male_28);
RoundedImageView img24 = (RoundedImageView) findViewById(R.id.avatar24);
img24.setImageResource(R.mipmap.avatars_male_29);
RoundedImageView img25 = (RoundedImageView) findViewById(R.id.avatar25);
img25.setImageResource(R.mipmap.avatars_male_30);
for (i = 1;i>25; i++){
j=(String) i;
//need a loop that dynamically sets img**2** (any number)
img<j>.setImageResource(R.mipmap.avatars_male_30);
}
將圖像添加到列表或數組? – mayha
創建一個列表'List',然後迭代你的列表。方便,快速:) –