ImageView不会更新

时间:2013-10-22 18:29:29

标签: android android-imageview

我正在尝试从imageview更新图像,调试它我看到它正在传递所有代码,但图像不会更新。 这是我的代码:

    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);

1 个答案:

答案 0 :(得分:1)

尝试拨打view.invalidate()。必须从UI线程调用此方法。要从非UI线程调用,请调用postInvalidate()

相关问题