The method Picture receives a random int i. I want to add i to the R.drawable.pic+i
in order to randomly choose between several drawables in the resource folder (pic0,pic1,pic2,…) and set them as background at the end of the view k. How can I do it? Here’s the code I have now:
public void Picture(int i){
View k = new View(NewGame.this);
k.setBackgroundResource(R.drawable.pic);
// here it should be k.setBackgroundResource(R.drawable.pic1); for example
setContentView(k);
}
the code that worked for me is :