title: Android layout xml causing npe
body: <p>I have a problem with a null pointer exception and I dont understand why. Please dont mark this as a dup of the thread "null pointer exception and how to fix it" as that thread is not relevant at all.  </p>
  
  <p>I do know what an npe is. And thus, I dont need that explained. </p>
  
  <p>So, to the problem:</p>
  
  <p>I have a dialog with a custom layout</p>
  
  <p>The layout xml file contains a linearlayout with a tablelayout inside. When I completly remove the tablelayout the npe goes away. Thus, I conclude that it has to be something wrong with the XML. </p>
  
  <p>Android studio however, gives no errors. </p>
  
  <p>Here is a link to the xml in question: </p>
  
  <p><a href="https://stackoverflow.com/questions/38879730/null-pointer-exception-when-trying-to-open-a-dialogbox-from-fragment-android">https://stackoverflow.com/questions/38879730/null-pointer-exception-when-trying-to-open-a-dialogbox-from-fragment-android</a></p>
  
  <p>Edit:</p>
  
  <p>Here is the full XML code:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:orientation="vertical" android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  android:weightSum="1"&gt;
  
  &lt;TextView
      android:layout_width="match_parent"
      android:layout_height="25dp"
      android:text="Alarm info"
      android:id="@+id/alarm_fragment_dialog_title"
      android:textSize="20dp"
      android:textColor="#000"
      android:textAlignment="center" /&gt;
  
  &lt;TableLayout
      android:layout_width="match_parent"
      android:layout_height="376dp"
      android:layout_marginTop="15dp"
      android:layout_gravity="center_horizontal"&gt;
  
      &lt;TableRow android:layout_marginTop="5dp"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
          &lt;TextView
              android:layout_column="1"
              android:text="Enhetens navn:"
              android:textColor="#000"
              android:layout_weight="3"
              android:layout_width="match_parent"
              android:layout_height="match_parent" /&gt;
          &lt;TextView
              android:text="Ctrl-O"
              android:textColor="#000"
              android:layout_weight="5"
              android:layout_width="match_parent"
              android:layout_height="match_parent" /&gt;
      &lt;/TableRow&gt;
  
      &lt;TableRow android:layout_marginTop="5dp"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
          &lt;TextView
              android:layout_column="1"
              android:text="Tidspunkt:"
              android:textColor="#000"
              android:layout_weight="3"
              android:layout_width="match_parent"
              android:layout_height="match_parent" /&gt;
          &lt;TextView
              android:text="Ctrl-O"
              android:textColor="#000"
              android:layout_weight="5"
              android:layout_width="match_parent"
              android:layout_height="match_parent" /&gt;
      &lt;/TableRow&gt;
  
      &lt;TableRow android:layout_marginTop="5dp"
          android:layout_width="match_parent"
          android:layout_height="match_parent"&gt;
          &lt;TextView
              android:layout_column="1"
              android:text="Posisjon:"
              android:textColor="#000"
              android:layout_weight="3"
              android:layout_width="match_parent"
              android:layout_height="match_parent" /&gt;
          &lt;TextView
              android:text="Ctrl-O"
              android:textColor="#000"
              android:layout_weight="5"
              android:layout_width="match_parent" /&gt;
      &lt;/TableRow&gt;
  &lt;/TableLayout&gt;
  
  &lt;EditText
      android:layout_width="match_parent"
      android:layout_height="match_parent" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Edit 2: Adding Java code</p>
  
  <pre><code>@Override
  public void onItemClick(AdapterView&lt;?&gt; adapterView, View view, int i, long l) {
  
          Dialog dialog = new Dialog(getContext());
  
          dialog.setContentView(R.layout.alarm_details_dialog);
  
          dialog.show();
  
     }
  </code></pre>