title: How to inflate RelativeLayout from XML
body: <p>I got a very specific task to inflate view. To be honest i dont really understand what I should do exactly. The only method, which compiled probperly was that</p>
  
  <pre><code>@Override
      public View getView(int position, View convertView, ViewGroup parent) {
  
  
          //TODO - Get the current ToDoItem
          final ToDoItem toDoItem =  mItems.get(position);
  
          //TODO - Inflate the View for this ToDoItem
          // from todo_item.xml.
  
            RelativeLayout itemLayout = (RelativeLayout)convertView.findViewById(R.id.RelativeLayout1);``
  </code></pre>
  
  <p>But now I got null pointer. So how should I properly inflate it? XML code below.</p>
  
  <pre><code>02-21 09:21:11.260: E/AndroidRuntime(1506): FATAL EXCEPTION: main
  02-21 09:21:11.260: E/AndroidRuntime(1506): java.lang.NullPointerException
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at course.labs.todomanager.ToDoListAdapter.getView(ToDoListAdapter.java:93)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.widget.HeaderViewListAdapter.getView(HeaderViewListAdapter.java:220)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.widget.AbsListView.obtainView(AbsListView.java:2177)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.widget.ListView.makeAndAddView(ListView.java:1840)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.widget.ListView.fillSpecific(ListView.java:1321)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.widget.ListView.layoutChildren(ListView.java:1633)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.widget.AbsListView.onLayout(AbsListView.java:2012)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.view.View.layout(View.java:14289)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.view.ViewGroup.layout(ViewGroup.java:4562)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.view.View.layout(View.java:14289)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.view.ViewGroup.layout(ViewGroup.java:4562)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at com.android.internal.widget.ActionBarOverlayLayout.onLayout(ActionBarOverlayLayout.java:349)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.view.View.layout(View.java:14289)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.view.ViewGroup.layout(ViewGroup.java:4562)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.widget.FrameLayout.onLayout(FrameLayout.java:448)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.view.View.layout(View.java:14289)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.view.ViewGroup.layout(ViewGroup.java:4562)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.view.ViewRootImpl.performLayout(ViewRootImpl.java:1976)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1730)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1004)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5481)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.view.Choreographer.doCallbacks(Choreographer.java:562)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.view.Choreographer.doFrame(Choreographer.java:532)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.os.Handler.handleCallback(Handler.java:730)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.os.Handler.dispatchMessage(Handler.java:92)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.os.Looper.loop(Looper.java:137)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at android.app.ActivityThread.main(ActivityThread.java:5103)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at java.lang.reflect.Method.invokeNative(Native Method)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at java.lang.reflect.Method.invoke(Method.java:525)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
  02-21 09:21:11.260: E/AndroidRuntime(1506):     at dalvik.system.NativeStart.main(Native Method)
  
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/RelativeLayout1"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical" &gt;
  
      &lt;TextView
          android:id="@+id/titleView"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true"
          android:textAppearance="?android:attr/textAppearanceLarge" &gt;
      &lt;/TextView&gt;
  
      &lt;TextView
          android:id="@+id/StatusLabel"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignBaseline="@+id/statusCheckBox"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true"
          android:layout_marginTop="17dp"
          android:text="@string/done_string" &gt;
      &lt;/TextView&gt;
  
      &lt;CheckBox
          android:id="@+id/statusCheckBox"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:layout_marginTop="52dp"
          android:layout_toRightOf="@+id/StatusLabel" &gt;
      &lt;/CheckBox&gt;
  
      &lt;TextView
          android:id="@+id/PriorityLabel"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignBaseline="@+id/statusCheckBox"
          android:layout_alignTop="@+id/StatusLabel"
          android:layout_toLeftOf="@+id/priorityView"
          android:text="@string/priority_string" &gt;
      &lt;/TextView&gt;
  
      &lt;TextView
          android:id="@+id/priorityView"
          android:layout_width="50dip"
          android:layout_height="wrap_content"
          android:layout_alignBaseline="@+id/statusCheckBox"
          android:layout_alignParentRight="true"
          android:layout_alignTop="@+id/StatusLabel" &gt;
      &lt;/TextView&gt;
  
      &lt;TextView
          android:id="@+id/DateLabel"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/statusCheckBox"
          android:text="@string/date_string" &gt;
      &lt;/TextView&gt;
  
      &lt;TextView
          android:id="@+id/dateView"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignBaseline="@+id/DateLabel"
          android:layout_toRightOf="@+id/DateLabel" &gt;
      &lt;/TextView&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>