title: Create a list when clicked on an imagebutton
body: <p>hey guys this is arjun narahari
  i m experiencing a problem while creating a list when clicked on an imagebutton
  need some assistance from u guys
  posting the code down here</p>
  
  <p>This is my homepage.java where my imagebutton is at the topright</p>
  
  <pre><code>package com.nb.list;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.ArrayAdapter;
  import android.widget.Button;
  import android.widget.ImageButton;
  import android.widget.ListView;
  
  public class HomePage extends Activity {
  
  ImageButton stats;
  ListView lv;
  String[] info = { "Mary(Wife)", "Alex(child-1)", "Steven(child-2)",
          "Robert(Father)", "Diana(Mother)" };
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.homepage);
  
  
      stats = (ImageButton) findViewById(R.id.imgstts);
  
      stats.setOnClickListener(new OnClickListener() {
  
          @Override
          public void onClick(View v) {
              // TODO Auto-generated method stub
              ArrayAdapter&lt;String&gt; adapter = new ArrayAdapter&lt;String&gt;(
                      getBaseContext(), android.R.layout.simple_list_item_1,
                      info);
              lv.setAdapter(adapter);
          }
      });
  }
  </code></pre>
  
  <p>}</p>
  
  <p>my list.xml file</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent" &gt;
  
  &lt;ListView
      android:id="@android:id/list"
      android:layout_width="match_parent"
      android:layout_height="match_parent" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>i m getting an error when clicked on the imagebutton , the app stops
  and in eclipse 
  it shows</p>
  
  <pre><code>10-23 17:23:30.914: E/AndroidRuntime(1296): FATAL EXCEPTION: main
  10-23 17:23:30.914: E/AndroidRuntime(1296): java.lang.NullPointerException
  10-23 17:23:30.914: E/AndroidRuntime(1296):     at com.nb.vaultHR.HomePage$5.onClick(HomePage.java:88)
  10-23 17:23:30.914: E/AndroidRuntime(1296):     at android.view.View.performClick(View.java:4204)
  10-23 17:23:30.914: E/AndroidRuntime(1296):     at android.view.View$PerformClick.run(View.java:17355)
  10-23 17:23:30.914: E/AndroidRuntime(1296):     at android.os.Handler.handleCallback(Handler.java:725)
  10-23 17:23:30.914: E/AndroidRuntime(1296):     at android.os.Handler.dispatchMessage(Handler.java:92)
  10-23 17:23:30.914: E/AndroidRuntime(1296):     at android.os.Looper.loop(Looper.java:137)
  10-23 17:23:30.914: E/AndroidRuntime(1296):     at android.app.ActivityThread.main(ActivityThread.java:5041)
  10-23 17:23:30.914: E/AndroidRuntime(1296):     at java.lang.reflect.Method.invokeNative(Native Method)
  10-23 17:23:30.914: E/AndroidRuntime(1296):     at java.lang.reflect.Method.invoke(Method.java:511)
  10-23 17:23:30.914: E/AndroidRuntime(1296):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
  10-23 17:23:30.914: E/AndroidRuntime(1296):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
  10-23 17:23:30.914: E/AndroidRuntime(1296):     at dalvik.system.NativeStart.main(Native Method)
  10-23 17:23:33.303: I/Process(1296): Sending signal. PID: 1296 SIG: 9
  </code></pre>
  
  <p>can somebody guide me as where i m going wrong and what do i have to do to make it work
  thanking you</p>