title: Adding Image in a layout
body: <p>I want to add an Image in an existing Layout. I create the Image with this code snippet:
  <a href="http://www.inter-fuser.com/2009/12/android-reflections-with-bitmaps.html" rel="nofollow">http://www.inter-fuser.com/2009/12/android-reflections-with-bitmaps.html</a></p>
  
  <p>This class creates a ImageView with the right image. I want to add the Image in this layout:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="wrap_content"
      android:orientation="horizontal" &gt;
  
      &lt;include
          android:id="@+id/actionbar_back"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          layout="@layout/actionbar_back" /&gt;
  
      &lt;LinearLayout
          android:id="@+id/ll_ueberschrift"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:background="@color/gray" 
          android:gravity="center"
          android:layout_below="@id/actionbar_back" &gt;
  
          &lt;TextView
              android:id="@+id/tv_ueberschrift"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="Java" 
              android:layout_gravity="right" 
              android:textSize="30sp" /&gt;       
      &lt;/LinearLayout&gt;
  
  
          &lt;!--  ListRow Left sied Thumbnail image --&gt;
  
      &lt;LinearLayout
          android:id="@+id/ll_thumbnail" 
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:padding="3dip"      
          android:layout_alignParentLeft="true"
          android:layout_marginRight="5dip"
          android:layout_marginTop="20dp"
          android:layout_below="@id/ll_ueberschrift" &gt;
  
          &lt;ImageView
              android:id="@+id/iv_objekt"
              android:contentDescription="@string/description"
              android:layout_width="120sp"
              android:layout_height="120sp"
              android:paddingLeft="5dp" /&gt;
      &lt;/LinearLayout&gt;
  &lt;RelativeLayout&gt;
  </code></pre>
  
  <p>Now I try to add the Image to the existing ImageView:</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
     ...
  
     //Create an Image view and add our bitmap with reflection to it
     ImageView imageView = new ImageView(this);
     imageView.setImageBitmap(bitmapWithReflection);
     imageView.setPadding(5, 5, 5, 5);
  
      View linearLayout =  findViewById(R.id.ll_picture_and_reflection);
      ((LinearLayout) linearLayout).addView(imageView);
      setContentView(R.layout.objekt_einzeln); 
  }
  </code></pre>
  
  <p>But I just a get "NullPointerException".</p>
  
  <p>Any suggestion what to do or what is incorrect?
  Thank a lot</p>
  
  <p>EDIT: I meant "View linearLayout =  findViewById(R.id.iv_objekt);"</p>