0

I'm trying to update a image from a imageview, debugging it I saw that is passing by all the code, but the image doesn't update. Here is my code:

 LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflater.inflate(R.layout.activity_main, null); ImageView view = (ImageView) v.findViewById(R.id.img); view.setImageResource(R.drawable.head); 
10
  • it doesn't seem to me like you have 2 images. Commented Oct 22, 2013 at 18:32
  • Where are you calling this code? There's no context given as to where this code exists Commented Oct 22, 2013 at 18:33
  • try once using view.setBackgroundResource(R.drawable.head); Commented Oct 22, 2013 at 18:44
  • the first image is set directly on xml, using android:src="@drawable/leftarm" Commented Oct 22, 2013 at 18:50
  • 2
    dont setImageResource in onDraw method, do it when you want to change the ImageView and dont use LayoutInflatet as you have your ImageView already in the view hierarchy Commented Oct 22, 2013 at 19:17

2 Answers 2

1

Try to call view.invalidate(). This must be called from a UI thread. To call from a non-UI thread, call postInvalidate().

Sign up to request clarification or add additional context in comments.

Comments

0

try to call imageView.refreshDrawableState() after applying all parameters

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.