title: Unable to start activity ComponentInfo: java.lang.NullPointerException
body: <p>The <code>Exception</code>:</p>
  
  <p><code>Unable to start activity ComponentInfo{com.scytec.datamobile.vd.gui.android/com.scytec.datamobile.vd.gui.android.SelectedList}: java.lang.NullPointerException..</code>
  I just  want to show checkbox list view and on every check it display "checked", simply but i don't know why this gives me an exception.</p>
  
  <pre><code>public class SelectedList extends Activity implements IObserver{
  
          private ListView machine_listview;
          ArrayAdapter&lt;String&gt; adapter;
          ArrayList&lt;String&gt; arrayListofMachines;
          ArrayList&lt;String&gt; arrayListofMachineNumbers;
          Vector&lt;MDCMachineStatus&gt; machineStatus_vector;
          Handler handler;
  
          private static int oldPosition = 0;
          private Boolean firstClick = true;
  
  
  
  
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              // TODO Auto-generated method stub
              super.onCreate(savedInstanceState);
              setContentView(R.layout.machinelistview);
  
              machine_listview = (ListView) findViewById(R.id.machine_listview);
              machine_listview.setFastScrollEnabled(true);
  
              MachineStatusSingleton.Register(this);
  
              getData();
  
              adapter = new ArrayAdapter&lt;String&gt;(SelectedList.this, R.layout.selectedlist,R.id.text1, arrayListofMachines);
  
              machine_listview.setAdapter(adapter);
  
              machine_listview.setSelection(oldPosition);
  
  
              CheckBox chk=(CheckBox)findViewById(R.id.check);
              chk.setOnCheckedChangeListener(new OnCheckedChangeListener()
              {
  
         public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
          TextView txt=(TextView)findViewById(R.id.xtra);
          if (arg1)
              Log.d("", "abul, checked") ;
          else
               Log.d("", "abul, not checked") ;
  
         }
  
              }
              );
  
  
              machine_listview.setOnItemClickListener(new OnItemClickListener() {
  
                  public void onItemClick(AdapterView&lt;?&gt; arg0, View arg1, int position,
                          long arg3) {
                      // TODO Auto-generated method stub
                      oldPosition = position;
                      MachineStatusSingleton.setMachineNumber(arrayListofMachineNumbers.get(position));
                      SelectedList.this.finish();
  
  
                  }
  
              });
  
  
              handler = new Handler(){
                  public void handleMessage(android.os.Message msg) {
  
  
                      machine_listview.setAdapter(adapter);
                      adapter.notifyDataSetChanged();
  
                  };
              };
  
  
  
  
  
  
          }
  
          public void Update(ISubject arg0) {
              // TODO Auto-generated method stub
          }
  
          @Override
          public void onDestroy()
          {
              super.onDestroy();
  
              MachineStatusSingleton.Unregister(this);
          }
  
          private void getData(){
              machineStatus_vector = MachineStatusSingleton.GetData();
              arrayListofMachines = new ArrayList&lt;String&gt;();
              arrayListofMachineNumbers = new ArrayList&lt;String&gt;();
              for(MDCMachineStatus temp: machineStatus_vector){
                  arrayListofMachines.add(temp.toString());
                  arrayListofMachineNumbers.add(temp.getNumber());
              }
  
              Collections.sort(arrayListofMachines);
              Collections.sort(arrayListofMachineNumbers);
  
          }
  
  
          private void updateData(){
              getData();
  
              handler.sendEmptyMessage(0);
              adapter.notifyDataSetChanged();
              int index = machine_listview.getFirstVisiblePosition();
              View v = machine_listview.getChildAt(0);
              int top = (v == null) ? 0 : v.getTop();
  
              // ...
  
              // restore
              machine_listview.setSelectionFromTop(index, top);
          }
  
  
      }
  </code></pre>