private void setProductInfo(View v, ProductWrapper pWrapper) { TextView productName = (TextView) v.findViewById(R.id.productName); TextView productCount = (TextView) v.findViewById(R.id.productCount); productName.setText(pWrapper.getName(lngIndex)); if (pWrapper.getInStock() <= 0) { productCount.setText(AppRootActivity.words.get(Const.NOT_IN_STOCK)); } else { productCount.setText( AppRootActivity.words.get(Const.IN_STOCK) + " " + pWrapper.getInStock() + " " + pWrapper.getUnit()); } TextView pDesc = (TextView) v.findViewById(R.id.pDescription); TextView pLocation = (TextView) v.findViewById(R.id.pLocation); TextView pProducer = (TextView) v.findViewById(R.id.pProducer); pDesc.setText( AppRootActivity.words.get(Const.DESCRIPTION) + " " + pWrapper.getDescription(lngIndex)); pLocation.setText( AppRootActivity.words.get(Const.LOCATION) + " " + pWrapper.getLocationName(lngIndex)); pProducer.setText( AppRootActivity.words.get(Const.PRODUCER) + " " + pWrapper.getProducerName(lngIndex)); }
@Override public View getView(int position, View convertView, ViewGroup parent) { View view = null; lngIndex = ((AppRootActivity) context).getLanguage(); try { if (convertView != null) { view = convertView; } else { view = inflater.inflate(R.layout.product_item, parent, false); } productWrapper = wrappedProducts.get(position); productId = (int) productWrapper.getId(); setImageView(view, productWrapper); setProductInfo(view, productWrapper); setProductPrice(view, productWrapper); setOrderBtnListener(view); } catch (Exception e) { Log.e(TAG + "getView(): ", e.toString()); } view.setFocusable(false); return view; }
private void setImageView(View view, ProductWrapper pWrapper) { ImageView imageView = (ImageView) view.findViewById(R.id.productImage); imageView.setImageBitmap(pWrapper.getImage()); }
private void setProductPrice(View view, ProductWrapper pWrapper) { TextView productPrice = (TextView) view.findViewById(R.id.productPrice); productPrice.setText(pWrapper.getPricePerUnit() + " " + pWrapper.getCurrency(lngIndex)); TextView per = (TextView) view.findViewById(R.id.per); per.setText("per " + pWrapper.getUnit()); }