【发布时间】:2019-07-14 22:24:49
【问题描述】:
我目前有一个程序可以生成我想通过 Graphview 在折线图上表示的 Arraylist。在实例化图表的点时,我遇到了我不太理解的语法错误。
我尝试使用来自:https://github.com/jjoe64/GraphView/wiki/simple-graph 的示例代码作为为折线图实例化数据点的某种基础,但是当我尝试自己的实例化(通过我的数据数组列表的 for 循环)时,我得到意外的令牌错误。我试过在括号和括号周围移动,我确信这是我缺少的一些简单的东西,但我现在被卡住了。
//Example code I am utilizing for populating data points into graph
GraphView graph = (GraphView) findViewById(R.id.graph);
LineGraphSeries<DataPoint> series = new LineGraphSeries<>(new DataPoint[] {
new DataPoint(0, 1),
new DataPoint(1, 5),
new DataPoint(2, 3),
new DataPoint(3, 2),
new DataPoint(4, 6)
});
graph.addSeries(series);
//My version of populating data points into graph
GraphView graph = (GraphView) findViewById(R.id.graph);
LineGraphSeries<DataPoint> series = new LineGraphSeries<>(new DataPoint[]{
for (int i = 0; i < timerObjs.size(); i++) {
new DataPoint(i, timerObjs.get(i));
}
});
graph.addSeries(series);
- 第一个错误是 ')' 预期的,'}' 预期的
- 第二个错误是';'预计
- 第三个错误是 Unexpected Tokens
我不明白为什么第一行和第二行的错误没有被最后一个错误解决(它认为是意外标记)
【问题讨论】:
标签: java android android-graphview