title: Android ListView addHeaderView() nullPointerException for predefined Views defined in XML
body: <p>Trying to use <code>addHeaderView()</code> and <code>addFooterView()</code> for a <code>ListView</code>.  If I try to use a View that I've predefined in XML for either the header or footer, I get a null pointer exception. However, if I dynamically create a View using code, it works fine...</p>
  
  <pre><code>// This doesn't work... nullPointerException
  ListView lv = (ListView) findViewById(R.id.my_list_view);
  TextView header = (TextView) findViewById(R.id.my_header);
  lv.addHeaderView(header);
  
  // This works fine
  ListView lv = (ListView) findViewById(R.id.my_list_view);
  TextView header = new TextView(this);
  TextView.setHeight(30);
  TextView.setText("my header text!");
  lv.addHeaderView(header);
  </code></pre>
  
  <p>My stack trace:</p>
  
  <pre><code>Caused by: java.lang.NullPointerException
      at android.widget.ListView.clearRecycledState(ListView.java:522)
      at android.widget.ListView.resetList(ListView.java:508)
      at android.widget.ListView.setAdapter(ListView.java:440)
      at com.company.myapp.MyActivity.refreshList(MyActivity.java:85)
      at com.company.myapp.MyActivity.onCreate(MyActivity.java:37)
      at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
      ... 11 more
  </code></pre>
  
  <p>Any clues?</p>