title: Unable to start Activity Componentinfo (Adapter Constructor)
body: <p>I tried to create a simple listview. I've done it many times &amp; this is the first time i face such errors. Tried this in both Eclipse Luna &amp; indigo. Both have the same error.</p>
  
  <p>Here is where i create an instant of the adapter :</p>
  
  <pre><code>import java.util.ArrayList;
  import android.app.Activity;
  import android.os.Bundle;
  import android.widget.ListView;
  
  
  public class ActivityMain extends Activity {
  public ArrayList&lt;StructRemedy&gt; remedies = new ArrayList&lt;StructRemedy&gt;();
  private ListView               lstContent;
  public AdapterRemedy           adapter;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      lstContent = (ListView) findViewById(R.id.lstContent);
      adapter = new AdapterRemedy(remedies);
      randomPopulation();
      lstContent.setAdapter(adapter);
  }
  
  
  private void randomPopulation() {
      for (int i = 0; i &lt; 30; i++) {
          StructRemedy remedy = new StructRemedy();
          remedy.title = "Remedy" + i;
          remedy.description = "Desc" + i;
          remedy.rateValue = (float) (Math.random() * 5);
          remedy.type = "tisane";
          remedy.use = "Headaches";
          remedies.add(remedy);
      }
  
      adapter.notifyDataSetChanged();
  }
  
  }
  </code></pre>
  
  <p>Now the error log (The error referes to the line where i create the constructor , u know the "super" line) :</p>
  
  <pre><code>06-08 10:03:27.875: E/AndroidRuntime(2715): FATAL EXCEPTION: main
  06-08 10:03:27.875: E/AndroidRuntime(2715): java.lang.RuntimeException: Unable to start activity ComponentInfo{ahmad.azimi.app.herbal_remedies/test.test1.app.herbal_remedies.ActivityMain}: java.lang.NullPointerException
  06-08 10:03:27.875: E/AndroidRuntime(2715):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
  06-08 10:03:27.875: E/AndroidRuntime(2715):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
  06-08 10:03:27.875: E/AndroidRuntime(2715):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
  06-08 10:03:27.875: E/AndroidRuntime(2715):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
  06-08 10:03:27.875: E/AndroidRuntime(2715):     at android.os.Handler.dispatchMessage(Handler.java:99)
  06-08 10:03:27.875: E/AndroidRuntime(2715):     at android.os.Looper.loop(Looper.java:137)
  06-08 10:03:27.875: E/AndroidRuntime(2715):     at android.app.ActivityThread.main(ActivityThread.java:5041)
  06-08 10:03:27.875: E/AndroidRuntime(2715):     at java.lang.reflect.Method.invokeNative(Native Method)
  06-08 10:03:27.875: E/AndroidRuntime(2715):     at java.lang.reflect.Method.invoke(Method.java:511)
  06-08 10:03:27.875: E/AndroidRuntime(2715):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
  06-08 10:03:27.875: E/AndroidRuntime(2715):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
  06-08 10:03:27.875: E/AndroidRuntime(2715):     at dalvik.system.NativeStart.main(Native Method)
  06-08 10:03:27.875: E/AndroidRuntime(2715): Caused by: java.lang.NullPointerException
  06-08 10:03:27.875: E/AndroidRuntime(2715):     at android.widget.ArrayAdapter.init(ArrayAdapter.java:310)
  06-08 10:03:27.875: E/AndroidRuntime(2715):     at android.widget.ArrayAdapter.&lt;init&gt;(ArrayAdapter.java:153)
  06-08 10:03:27.875: E/AndroidRuntime(2715):     at test.test1.app.herbal_remedies.AdapterRemedy.&lt;init&gt;(AdapterRemedy.java:22)
  06-08 10:03:27.875: E/AndroidRuntime(2715):     at test.test1.app.herbal_remedies.ActivityMain.onCreate(ActivityMain.java:22)
  06-08 10:03:27.875: E/AndroidRuntime(2715):     at android.app.Activity.performCreate(Activity.java:5104)
  06-08 10:03:27.875: E/AndroidRuntime(2715):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
  06-08 10:03:27.875: E/AndroidRuntime(2715):     at 
  android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
  </code></pre>
  
  <p>This is the adapter :</p>
  
  <pre><code>import java.util.ArrayList;
  import android.content.Intent;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.view.ViewGroup;
  import android.widget.ArrayAdapter;
  import android.widget.ImageView;
  import android.widget.RatingBar;
  import android.widget.TextView;
  
  
  public class AdapterRemedy extends ArrayAdapter&lt;StructRemedy&gt; {
  
      public AdapterRemedy(ArrayList&lt;StructRemedy&gt; remedies) {
          super(G.context, R.layout.adapter_notes, remedies);
      }
  
  
      private static class ViewHolder {
  
          public TextView  txtTitle;
          public TextView  txtType;
          public TextView  txtFor;
          public RatingBar rating;
          public ViewGroup layoutRoot;
          public ImageView imgLogo;
  
  
          public ViewHolder(View view) {
              layoutRoot = (ViewGroup) view.findViewById(R.id.layoutRoot);
              txtTitle = (TextView) view.findViewById(R.id.txtTitle);
              txtType = (TextView) view.findViewById(R.id.txtType);
              txtFor = (TextView) view.findViewById(R.id.txtFor);
              rating = (RatingBar) view.findViewById(R.id.rate);
              imgLogo = (ImageView) view.findViewById(R.id.imgLogo);
  
          }
  
  
          public void fill(final ArrayAdapter&lt;StructRemedy&gt; adapter, final StructRemedy item, final int position) {
              txtTitle.setText(item.title);
              txtType.setText(item.type);
              txtFor.setText(item.use);
              rating.setRating(item.rateValue);
              //imgLogo.setImageBitmap(bm);
  
              layoutRoot.setOnClickListener(new OnClickListener() {
  
                  @Override
                  public void onClick(View view) {
                      Intent intent = new Intent(G.currentActivity, ActivitySelect.class);
                      intent.putExtra("POSITION", position);
                      G.currentActivity.startActivity(intent);
                  }
              });
  
          }
      }
  
  
      @Override
      public View getView(int position, View convertView, ViewGroup parent) {
          ViewHolder holder;
  
          StructRemedy item = getItem(position);
          if (convertView == null) {
              convertView = G.inflater.inflate(R.layout.adapter_notes, parent, false);
              holder = new ViewHolder(convertView);
              convertView.setTag(holder);
          } else {
              holder = (ViewHolder) convertView.getTag();
          }
          holder.fill(this, item, position);
          return convertView;
      }
  }
  </code></pre>