コード例 #1
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

    View view = context.getLayoutInflater().inflate(R.layout.list_item_card, parent, false);

    Product produto = getItem(position);

    ImageView productImage = (ImageView) view.findViewById(R.id.card_item_product_image);
    TextView productName = (TextView) view.findViewById(R.id.card_item_product_name);
    TextView productUnitaryPrice = (TextView) view.findViewById(R.id.card_item_product_unitPrice);
    TextView productStock = (TextView) view.findViewById(R.id.card_item_product_stock);

    // new ProductBitmapTask(produto.getImage(),productImage).execute();
    productName.setText(produto.getName());
    productStock.setText(produto.getStock().toString());
    productUnitaryPrice.setText(produto.getUnitPrice().toString());

    /*
    try {
        Bitmap bitmap = BitmapFactory.decodeByteArray(produto.getImage(), 0, produto.getImage().length);
        productImage.setImageBitmap(bitmap);
    }catch (Exception e){
        productImage.setImageResource(R.drawable.no_image_found);
    }
    */

    return view;
  }
コード例 #2
0
  @Override
  public View getView(int i, View view, ViewGroup viewGroup) {
    Product product = getItem(i);
    View productListItemView =
        context.getLayoutInflater().inflate(R.layout.product_list_item, null);

    View imageView = (View) productListItemView.findViewById(R.id.product_list_vw_image);
    imageView.setBackgroundColor(Color.GRAY);

    TextView productName = (TextView) productListItemView.findViewById(R.id.productName);
    productName.setText(" " + product.getName());

    TextView productPrice = (TextView) productListItemView.findViewById(R.id.productPrice);
    productPrice.setText(" " + product.getPrice().toString());

    TextView productQuantity = (TextView) productListItemView.findViewById(R.id.productQuantity);
    productQuantity.setText(" " + product.getQuantity().toString());

    return productListItemView;
  }