我有一個這樣的數組:的方法添加到一個ArrayList中退出
ArrayList<FuelData> arrValue = objrp.FuelReport(AccountID,
deviceID, datefrom, dateto, timezone, timefrom, timeto);
for (int i = 0; i < arrValue.size(); i++) {
String statusDescription = StatusCode.getDescription(AccountID,
arrValue.get(i).GetStatusCode(), privLabel, null);
String detail = "Mức nhiên liệu:"
+ Math.round(arrValue.get(i).GetFuelLevel())
+ " l\\nQuãng đường đi được:"
+ Math.round(arrValue.get(i).GetFuelLevel())// adding GetOdometer here
+ " km\\nThời gian: "
+ ConvertFromEpoch(arrValue.get(i).getTimeStamp())
+ "\\nĐịa điểm:"
+ GetUTF8FromNCRDecimalString(arrValue.get(i)
.getAddress()) + "\\nTrạng thái: "
+ GetUTF8FromNCRDecimalString(statusDescription);
strscr += "chartData.push({fuelLevel: "
+ arrValue.get(i).GetFuelLevel() + ",odometerKm: "
+ arrValue.get(i).GetOdometerKM() + ", detail:\""
+ detail + "\"});\n";
}
現在我想將這個方法添加:
GetOdometer(String accountID, String deviceID, String timestamp)
這一行:+ Math.round(arrValue.get(i).GetFuelLevel())// adding GetOdometer here
此法不屬於FuelData類,但在其他類。我可以這樣做,如果可以,我該怎麼辦?
這不是'array'它是'ArrayList' – 2014-10-03 04:47:27
創建另一個類的實例,然後使用'instance.getOdometer()'調用它 – Tirath 2014-10-03 04:48:32
@Tirath我也這樣做了你的建議,但我仍然不能得到getOdometer()的值 – dailammoc 2014-10-03 04:53:06