Skip to content Skip to sidebar Skip to footer

Android - Error With Listview In Adapter : Java.lang.nullpointerexception

I'm facing this error in displaying a List View. The problem is in the adapter but I couldn't find the solution. This in my logcat : FATAL EXCEPTION: main java.lang.NullPointerExce

Solution 1:

That's because when you inflate your view:

if (row == null) {
        LayoutInflater inflater = LayoutInflater.from(context);
        row = inflater.inflate(layoutResourceId, parent, false);

        holder = new ViewHolder();
        holder.imageType = (ImageView) row
                .findViewById(R.id.imageTypeWorkitem);
        holder.type = (TextView) row.findViewById(R.id.typeWorkitem);
        holder.imagePriority = (ImageView) row
                .findViewById(R.id.imagePriority);
        holder.key = (TextView) row.findViewById(R.id.key);
        holder.imageStatus = (ImageView) row.findViewById(R.id.imageStatus);
        holder.status = (TextView) row.findViewById(R.id.status);

        row.setTag(holder);

you don't initialize the priority field.

Post a Comment for "Android - Error With Listview In Adapter : Java.lang.nullpointerexception"