I 'm devoloping an app with a listview , every row is populated with various objects including a Textview with int value, how can I average out the valus contained in the textview in my listview ? thanks
How to average out values of Textview inside a listView
548 Views Asked by Andrea Cinesi At
2
There are 2 best solutions below
0

Assuming the calculation of that average will be performed on some view click which is not a part of ListView
.
In ListView
's Adapter
you must be passing the ArrayList
of some Java Model class. That class will have one variable which will represent the value entered by user. You have to store the value on focus change listener.
After user click the Calculate Average button. You simply iterate through the ArrayList
and apply the formula of average i.e. Sum of All Values/ Number
of Values
you should implement a method of counting the average values in your adapter
this is not the end result you will need to adjust for themselves