How to change the image of an ImageView dynamically [closed]

6

Hello, I need help to dynamically change an image

Follow my code:

st = (ImageView) findViewById(R.id.imageView4);
int RID = this.getApplicationContext().getResources().getIdentifier(Bundle_img, "drawable", getPackageName());
st.setImageResource(RID );

The above code is not replacing the previous image.

    
asked by anonymous 03.08.2015 / 19:07

1 answer

0

Try to use getResources().getDrawable(R.drawable.nome_imagem) .

Example:

Drawable drawable= getResources().getDrawable(R.drawable.nome_imagem);
img.setImageDrawable(drawable);
    
05.08.2015 / 15:09