gpt4 book ai didi

Android graphview不会自动更新

转载 作者:行者123 更新时间:2023-11-29 01:53:03 24 4
gpt4 key购买 nike

我正在使用 GraphView 库,但在更新系列(或用新系列替换系列)时无法让图表自行重绘。当我触摸屏幕时,它似乎只会重新绘制自己。这是我的更新功能。

private void updateGraph(Animal a)
{
Toast.makeText(getApplicationContext(), "Updating Graph", Toast.LENGTH_SHORT).show();
GraphViewData[] newData = new GraphViewData[2];
newData[0] = new GraphViewData(0,a.getAvg());
newData[1] = new GraphViewData(1,0.2);

GraphViewSeries newSeries = new GraphViewSeries(a.getName(),dStyle,newData);

graph.removeSeries(exampleSeries);
graph.addSeries(newSeries);
//update horizontal value
//graph.setHorizontalLabels(new String[]{a.getName()});
}

最佳答案

我想通了...

//test random y value
double rnd = generator.nextDouble();

// round is an incremental value (1,2,3...)
GraphViewData newData = new GraphViewData(round,rnd);

exampleSeries.appendData(newData, false);
graph.redrawAll();

关于Android graphview不会自动更新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16794987/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com