I have a list view. Each list view contain spinner and I want to get the value of each spinner. But it doesn't work. It is ok if the listview is not scroll able.
private void checkPrice(){
float total = 0;
Log.d(TAG,"This is qty: "+ quantity);
for (int i=0; i < mProductItems.size(); i++){
View view = mListView.getChildAt(i);
float eachTotal = 0;
float discountAmount = 0;
// Get Quantity
Spinner getQtyView = (Spinner) view.findViewById(R.id.spQty);
String getQty = getQtyView.getSelectedItem().toString();
Integer qty = Integer.parseInt(getQty);
// Get Line item amount view
TextView txvAmount = (TextView) view.findViewById(R.id.txvAmount);
// Get product by view position
OEDataRow eachProduct = (OEDataRow) mProductItems.get(i);
Integer eachPrice = eachProduct.getInt("retail_price");
// Check Discount
if (eachProduct.getBoolean("promotion_disc")){
float promo = (float) eachProduct.getInt("promotion_amount")/100;
Log.d(TAG,"this is promo: "+promo);
discountAmount = (float)( eachPrice * qty ) * promo;
}else {
discountAmount = 0;
}
eachTotal = (float)( eachPrice * qty ) - discountAmount;
txvAmount.setText(String.format("%.2f", eachTotal));
Log.d(TAG, "Each Total: " + eachTotal);
total = eachTotal + total;
Log.d(TAG,"Total: "+ total);
}
btnCheckout.setText("Checkout: "+String.format("%.2f", total));
}
Thanks for your time.