Total quantity selected memorandum

Check the check boxes in the list view Creating a process to display on toast after pressing the button

Image display is temporarily closed. Lol

private ArrayList<QuantityInfo> list = new ArrayList<>();
    private void selectList() {
        int sum = 0;

        for (QuantityInfo info : list) {
            //If the check box is checked
            if (info.isSelected()) {
                //Add quantity
                sum += info.quantity;
            }
        }
        //Result display on toast
        String viewQuantity = String.valueOf(sum);
        Toast.makeText(MainActivity.this, viewQuantity, Toast.LENGTH_SHORT).show();
    }

Is it the process of pressing the list view that took time? I was confused in my head whether it was the process of pressing the check box.

The position of the view was completely irrelevant, and it was a simpler process than I expected.

It takes some getting used to using the extended for statement, but I wonder if I can understand it in my head ...

Recommended Posts

Total quantity selected memorandum
@quantity
memorandum
memorandum