I have 100 images, each is an image of a percentage, for example, 1%, 2%, 3%, etc.
What's the best way to go through each image? Should I add each image resource to a List or Dictionary(if that exists in Android). Or am I forced to hard code it?
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);
}
});
}
At OP's request, answering with a copypasta from a comment:
Have a look at How do I iterate through the id properties of R.java class? and Android: Programatically iterate through Resource ids.
...though this question should really just be closed as a dup.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With