我有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