Calling arrValue.get(i)
fetches you the object of FuelData
class at i
th index in the arrValue
arraylist.
Now, if the method getOdometer()
is defined inside FuelData
– You should be able to access it using the below statement
arrValue.get(i).getOdometer("value1", "value2", "value3")
Make sure getOdometer
method returns a string or atleast it returns something.
Also, as I noticed you mentiioned this method is not defined in FuelData
. Then you should be fine doing the below
//create Instance Of This Other Class before the for loop
//then call `GetOdometer(String accountID, String deviceID, String timestamp)`
//make sure GetOdometer is returning something
//follow camel casing for naming methods
For example,
///create instance
OtherClass c = new otherClass();
for (int i = 0; i < arrValue.size(); i++) {
.
.
String detail = "Mức nhiên liệu:"
+ Math.round(arrValue.get(i).GetFuelLevel())
+ c.GetOdometer("value1", "value2", "value3")
Try above code change only if GetFuelLevel
methods behavior is same for all the objects of this OtherClass
. Otherwise move
OtherClass c = new otherClass();
inside the for loop. Let me know in the comments if it does not work.
0
solved Add a method to an exited ArrayList