ImageView Android
<p><strong>Method1  (Not working)</strong>
I declared an Imageview in XML</p>

<pre><code>&lt;ImageView
    android:id="@+id/imageView1" 
    android:layout_height="wrap_content"
    android:layout_weight="0.21" 
    android:layout_width="100dp" 
    android:layout_gravity="center"&gt;
&lt;/ImageView&gt;
</code></pre>

<p>Then I declare it in code </p>

<pre><code>ImageView iv=(ImageView)findViewById(R.id.imageView1);
</code></pre>

<p>Then I download a image from web (image)</p>

<pre><code>iv.setImageBitmap(image);
setContentView(iv);
</code></pre>

<p><strong>Method2 (working)</strong></p>

<p>Instead of XML  i just declare</p>

<pre><code>ImageView iv=new ImageView(this);
</code></pre>

<p>Then I download a image from web (image)</p>

<pre><code>iv.setImageBitmap(image);
 setContentView(iv);
</code></pre>

<p><strong>The question why Method1 doesn't work and Method2 works?</strong></p>
