0

I'm trying to retrieve some data from my database table called Products. The problem is while trying to test my code it gives me this "Unfortunately, 'app' has stopped". And when I looked in my app logcat report, I got this:

logcat report:

logcat report

Here is CustomAdapter class:

public class CustomAdapter extends BaseAdapter {

    Context c;
    LayoutInflater inflater;
    ArrayList<ProductObjects>  productObjects;

    public CustomAdapter(Context context,ArrayList<ProductObjects>  productObjects) {
        this.c = context;
        this .productObjects = productObjects;
    }

    @Override
    public int getCount() {
        return productObjects.size();
    }

    @Override
    public Object getItem(int position) {
        return productObjects.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ProductHolder productHolder;

        if (convertView==null) {
            inflater = LayoutInflater.from(c);
            convertView = inflater.inflate(R.layout.model, parent, false);

            productHolder = new ProductHolder();
            productHolder.nameTXT = (TextView) convertView.findViewById(R.id.nameTXT);
            productHolder.price = (TextView) convertView.findViewById(R.id.price);
            productHolder.Image = (ImageView) convertView.findViewById(R.id.product_image);

            convertView.setTag(productHolder);
        }

        else{

            productHolder = (ProductHolder) convertView.getTag();
        }
        ProductObjects productObjects;
        productObjects = (ProductObjects) this.getItem(position);

        productHolder.nameTXT.setText(productObjects.getProduct_name());
        productHolder.price.setText(productObjects.getPrice());

        PicassoClient.downloadImage(c,productObjects.getProduct_image(),productHolder.Image);


        return convertView;
    }

    public static class ProductHolder{

        TextView nameTXT,price;
        ImageView Image;

    }
}

Can you explain what's going wrong, please?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
tasneem
  • 1
  • 1

0 Answers0