Insert Image in code, Android Setimage, Error while doing dynamic in java

Asked

Viewed 32 times

0

ImageView img = (ImageView) findViewById(R.id.img);
//Atualizando a imagem dinamicamente. A classe R é utilizada para acessar o recurso.
img.setImageResource(R.drawable.img);

There’s a mistake, I wonder where I’m going wrong

  • 1

    "An error happens" - But which ? Without knowing what the error is literally impossible to help.

1 answer

0

Try it this way

SeuContexto.getDrawable(R.drawable.img)
  • Nothing. the error persists

  • Please edit your question and place the error. @Vitorgiovanny

Browser other questions tagged

You are not signed in. Login or sign up in order to post.