Android : trouble setting image dynamically
<p>I am changing the image resource in an ImageView dynamically from the resources folder using a seperate handler. But at times, the image minimizes. What could cause this issue ? Looks like it is getting redrawn to a very small size. what could be causing this issue ?</p>

<pre><code>    int drawableId = -1;
private void loadImageViewWithImageString(ImageView imgView, String image) {

    try {
        Class&lt;drawable&gt; res = R.drawable.class;
        Field field = res.getField(image);
        drawableId = field.getInt(null);
    }
    catch (Exception e) {
        Log.e("MyTag", "Failure to get drawable id.", e);
    }
    handler.post(new Runnable() {

        @Override
        public void run() {
            if(drawableId != -1){
                //wDisplayImgView.setImageDrawable(getResources().getDrawable(drawableId));
                wDisplayImgView.setImageResource(drawableId);

            }else{
                wDisplayImgView.setImageDrawable(getResources().getDrawable(R.drawable.default_weather_icon));

            }
            wDisplayImgView.invalidate();
            subCoreLayout.invalidate();

        }

    });

}
</code></pre>
