title: Android: getting null pointer exception while setAdapter()
body: <p>I am very new to Android programming.I am trying to create a basic list app.I am geting nullpointer exception while setting adapter using setAdapter().My code for the same is as follows.</p>
  
  <p><strong>ListAdapter.java</strong></p>
  
  <pre><code>package com.example.listexmpl;
  import java.util.ArrayList;
  
  import android.view.LayoutInflater;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.BaseAdapter;
  import android.widget.TextView;
  
  public class ListAdapter extends BaseAdapter{
  
      private ArrayList&lt;ListRecord&gt; records = new ArrayList&lt;ListRecord&gt;();
  
  
      public ListAdapter(){
          records.add(new ListRecord("Rajat","I'm feeling very happy today."));
      }
  
      @Override
      public int getCount() {
          // TODO Auto-generated method stub
          return records.size();
      }
  
      @Override
      public Object getItem(int index) {
          // TODO Auto-generated method stub
          return getItem(index);
      }
  
      @Override
      public long getItemId(int index) {
          // TODO Auto-generated method stub
          return index;
      }
  
      @Override
      public View getView(int index, View view, ViewGroup parent) {
          // TODO Auto-generated method stub
          if(view==null){
              LayoutInflater inflater = LayoutInflater.from(parent.getContext());
              view = inflater.inflate(R.layout.list_record,parent,false);
          }
          ListRecord listr = records.get(index);
          TextView nameView = (TextView) view.findViewById(R.id.name_view);
          TextView statView = (TextView) view.findViewById(R.id.stat_view);
          nameView.setText(listr.getName());
          statView.setText(listr.getStatus());
          return view;
      }
  
  }
  </code></pre>
  
  <p><strong>ListActivity.java</strong></p>
  
  <pre><code>package com.example.listexmpl;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.view.Menu;
  import android.widget.ListView;
  
  public class ListActivity extends Activity {
  
      ListAdapter lstrecordAdapter;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_list);
          ListView lstview = null;
          lstview = (ListView) findViewById(R.id.list_record);
          lstrecordAdapter = new ListAdapter();
          lstview.setAdapter(lstrecordAdapter);
      }
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.activity_list, menu);
          return true;
      }
  
  }
  </code></pre>
  
  <p>When I put the statement containing setAdapter() in try-catch block the app runs but there is nothing to see on screen except the app header.Where am I going wrong?</p>
  
  <p><strong>[edit]</strong>
  activity_list.xml</p>
  
  <pre><code>&lt;ListView xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      &gt;
  
  &lt;/ListView&gt;
  </code></pre>