I have an unsolved problem: what I want to do: I have an activity with a TextView which shows the mathematical sum of all items: example. The Listview contains several items which have an amount (double). I want to show the sum of all items inside the activity.
Generally, it works fine when the activity runs the first time, but if I add an item to the list (with a button) later on it is shown correctly inside the list. but I have to update the Textview in the activity. how can I do that, because I don't know a function which tells me that da dataset has changed?
what works actually:
- the activity, the sum calculation, and the Listview (with custom adapter).
- In the Listview there is a checkbox, when it is changed a dialog is opened where the new amount is inserted. (that is all done in the adapter)
- everything is correctly shown in the listview after a change
What should be solved:
- Now, as soon as the dialog box is closed, the sum in the activity (which is outside of the Listview) has to be updated. but how do I get that information back to my activity?
Thank you for your support!
Best regards Jason
CodePudding user response:
The ListView is in the mainactivity and works fine. In the custom Adapter I can change some date of the Item (each line). Now the Data and ListView is updated and correctly shown. But not The TextView in the mainactivity.
I solved it now by passing the TextView object to the Custom Adapter and do the setText(....) there