0

Whenever items from listview are added or deducted the total should be updated. When I add items from listview the grand total is correct but when items are deslected the price of the product shd be deducted from grand total which is not happening. Any solutions?

adapter.registerDataSetObserver(new DataSetObserver() {
        @Override
        public void onChanged() {
            super.onChanged();

            int index = selectedList.indexOf(ordList.get(adapter.recentItemSelected));
            if (index >= 0) {
                selectedList.remove(index);
                rvOrderBrdAdapter.notifyItemRemoved(index);
                return;
            } else {
                selectedList.add(ordList.get(adapter.recentItemSelected));
                rvOrderBrdAdapter.notifyItemInserted(selectedList.size() - 1);

                return;
            }
        }
    });
public void totalOrderValue(ArrayList<OrderBrdDataModel> filteredlist) {
    double total = 0;
    for (int i = 0; i < filteredlist.size(); i++) {
        total = total + filteredlist.get(i).getBrdIndividualTotal();
    }
    totalValue.setText(String.format("%.3f", total));
}

1 Answer 1

0

I found solution.. Any other solutions welcomed.. had to call totalOrderValue(selectedList); inside my "if" block

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.