I am wondering how best to go about making this type of app. My wife told me to make it and I don't want to let her down. The use case is as follows.

Click Add Item Button Edit Text Type name of item Second Edit Text- Type Price As more prices get entered the subtotal reflects the added price so it keeps track of total cost and displays it via a label.

I would like the process repeating for each new store/price entered. .

I would like to be able to create unlimited items. I would like to use a listview so you can tap on each item to be able to view/modify it's contents.

Any help or tutorial that someone knows of would be awesome! Thanks!

Dani AI

Generated

For the scenario described by (and echoed by ) — an item name + price list with editable rows and a running subtotal — a simple, robust design is:

  • A small model class (for example: Item with name and priceInCents).
  • A modern list UI (prefer RecyclerView over ListView today).
  • Locale-aware parsing/formatting for money and storage as integers (cents) or BigDecimal to avoid floating-point errors.
  • Persistent storage (Room or simple JSON for tiny datasets) and background threads for DB work so the UI stays responsive.
  • Tap-to-edit implemented via a dialog or edit Activity that updates the data source and lets observers recalculate the subtotal.

Parsing and formatting examples (Java) to normalize input and present currency:

private long parsePriceToCents(String input) throws ParseException {
    String cleaned = input.replaceAll("[^0-9,\\.\\-]", "");
    DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.getDefault());
    char grouping = symbols.getGroupingSeparator();
    char decimal = symbols.getDecimalSeparator();
    cleaned = cleaned.replace(String.valueOf(grouping), "");
    if (decimal != '.') cleaned = cleaned.replace(decimal, '.');
    BigDecimal bd = new BigDecimal(cleaned).setScale(2, RoundingMode.HALF_UP);
    return bd.multiply(BigDecimal.valueOf(100)).longValueExact();
}

private String formatCents(long cents) {
    NumberFormat nf = NumberFormat.getCurrencyInstance();
    return nf.format(BigDecimal.valueOf(cents, 2));
}

Operational tips tied to the thread: compute the subtotal from stored cents whenever the dataset changes (LiveData/ViewModel makes this trivial), or maintain a running long and update it atomically on add/edit/delete. Validate EditText with inputType="numberDecimal" and guard against empty or malformed input. As reminded, include snippets of layouts or errors when asking follow-up questions so answers can be specific.

Further reading: RecyclerView guide, Room persistence library, and NumberFormat (Java).

Recommended Answers

All 2 Replies

The use case is as follows.

Click Add Item Button
Edit Text Type name of item
Second Edit Text- Type Price

Forum rules

Do provide evidence of having done some work yourself if posting questions from school or work assignments

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.