我从sqlite数据库(浮点数)获取数据并添加返回它们作为这样的Float arraylist方法 . (*注意:Arraylists初始化为全局变量)

public ArrayList<Float> getMonthLiters(){
    Cursor cursor = bd.monthQuery(base);
    for (cursor.moveToFirst(); !cursor.isAfterLast(); cursor.moveToNext()) {
        yNewData.add(cursor.getFloat(cursor.getColumnIndex("AVG(liters_field)")));
    }
    cursor.close();
    return yNewData;
}

然后我通过for循环将返回的arraylist添加到Entry Arraylist中,如下所示:

public void ShowMonthBar(){
           barH.clear();//Clears the chart of all data (by setting the data object to null). 
           for (int i = 0; i < getMonthLiters().size(); i++) {
               barEntry.add(new BarEntry(i, getMonthLiters().get(i)));
//ArrayList<BarEntry> barEntry = new ArrayList<>(); this is the global BarEntry arraylist
               xVals.add(getMonth().get(i));
           }
           cfgBar(barEntry);
           cfgBarDate(xVals);

       }

在此之后's just adding barEntry intro a new BarData object. For more context, i' m尝试将图表值(升)更改/更新/转换为galons或M ^ 3当我从微调器中选择它时,默认情况下图表将其显示为升,但是当我从此微调器中选择Galons时想要遍历barEntry arraylist并将升数除以3.785,然后将结果设置为新的barEntry并刷新图表 . 我只是想通过sql查询制作更多的方法来转换升或只是这样做: barEntry.add(new BarEntry(i, (getMonthLiters().get(i))/3.785));