NullPointerException in CustomAdapter for ListView
<p>hy!</p>

<p>I always get a NullPointerEx in my code. The list size is 7 so this can't be null. The customlistime exists. I have no idea where do i get the Exception. In my other programm this code worked.</p>

<p>Please help</p>

<p><strong>Calling:</strong></p>

<pre><code>Log.e("SP",String.valueOf(list.size())); //List size is 7
ca = new CustomAdapter(this, R.layout.customlistitem, list); //global var
lv.setAdapter(ca); //Error Occurs here
</code></pre>

<p><strong>CustomAdaptor:</strong></p>

<pre><code>public class CustomAdapter extends ArrayAdapter&lt;SPEntry&gt;{

    private ArrayList&lt;SPEntry&gt; entries;

    public CustomAdapter(Context context, int textViewResourceId,ArrayList&lt;SPEntry&gt; objects) {
        super(context, textViewResourceId, objects);
        this.entries = objects;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = new ViewHolder();
        LayoutInflater li = (LayoutInflater)CustomAdapter.this.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        if (convertView == null) {
            convertView = li.inflate(R.layout.customlistitem,null);
            holder.date = (TextView) convertView.findViewById(R.id.item_date);
            holder.lesson = (TextView) convertView.findViewById(R.id.item_lesson);
            holder.teacher = (TextView) convertView.findViewById(R.id.item_teacher);
            holder.image = (ImageView) convertView.findViewById(R.id.item_picture);
            convertView.setTag(holder);
        }
        else{
              holder = (ViewHolder) convertView.getTag();
        }
        holder.date.setText(entries.get(position).date);
        holder.teacher.setText(entries.get(position).teacher);
        holder.lesson.setText(entries.get(position).lesson);
        Bitmap bt = Bitmap.createScaledBitmap(entries.get(position).picture, 48, 48, false);
        holder.image.setImageBitmap(bt);
        return convertView;         
    } 

}
</code></pre>

<p><strong>Viewholder:</strong></p>

<pre><code>public class ViewHolder {

    public ImageView image;
    public TextView date;
    public TextView lesson;
    public TextView teacher;



    ViewHolder()
    {
    }
}
</code></pre>

<p>ErrorCode:</p>

<pre><code>10-17 20:49:39.481: ERROR/AndroidRuntime(2767): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.korn.supplierplan/com.korn.supplierplan.view.LVEntries}: java.lang.NullPointerException
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at android.app.ActivityThread.access$2200(ActivityThread.java:119)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at android.os.Looper.loop(Looper.java:123)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at android.app.ActivityThread.main(ActivityThread.java:4363)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at java.lang.reflect.Method.invokeNative(Native Method)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at java.lang.reflect.Method.invoke(Method.java:521)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at dalvik.system.NativeStart.main(Native Method)
10-17 20:49:39.481: ERROR/AndroidRuntime(2767): Caused by: java.lang.NullPointerException
10-17 20:49:39.481: ERROR/AndroidRuntime(2767):     at com.korn.supplierplan.view.LVEntries.onCreate(LVEntries.java:30)
</code></pre>

<p>Picture from ca in the debugger:</p>

<p><img src="http://img7.imagebanana.com/img/alen3q0g/Unbenannts.png" alt="enter image description here"></p>
