我有100个图像,每个图像的百分比,例如1%,2%,3%等。遍历图像
什么是通过每个图像的最佳方式?我应该将每个图像资源添加到列表或词典(如果存在于Android中)。还是我被迫硬编码?
public void ShowCircle(final int percentage){
final ImageView ring = (ImageView)findViewById(R.id.ring);
ring.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
for(int i = 0; i != percentage; i++)
//I was thinking here I can access list/dictionary records.
ring.setImageResource(R.drawable.percent_1);
}
});
}
看看[如何遍历R.java类的id属性?](http://stackoverflow.com/questions/2941459/how-do-i-iterate-through-the-id- r-java-class的属性)和[以编程方式遍历资源ID](http://stackoverflow.com/questions/3545196/android-programatically-iterate-through-resource-ids)。 –
@MattBall - 谢谢,'我如何迭代R.java类的id属性?'有我正在寻找的答案。 – Kukoy
我使用了MattBall建议的以下资源。 http://stackoverflow.com/questions/2941459/how-do-i-iterate-through-the-id-properties-of-r-java-class – Kukoy