我一直试图在Android应用程序上绘制两个ArrayLists的图表。我从ArrayList获得的值成功,但我不能调用方法来获取值。
我创建了这个从我的数据库中获取值的方法:
public DataPoint[] setData(String data)
{
TextView editText4;
editText4 = (TextView) findViewById(R.id.editText4);
String[] lucas = data.split(",");
List<String> ok = new ArrayList<String>(Arrays.asList(lucas));
List<String> yes = new ArrayList<String>(Arrays.asList(lucas));
int n = ok.size(); //to find out the no. of data-points
editText4.setText(String.valueOf(n));
DataPoint[] values = new DataPoint[n]; //creating an object of type DataPoint[] of size 'n'
for (int i = 0; i < n; i++)
{
DataPoint v = new DataPoint(Double.parseDouble(ok.get(i)), Double.parseDouble(yes.get(i)));
values[i] = v;
}
return values;
}
我的问题在于setData(无法解析符号&#39; setData&#39;):
GraphView graph;
PointsGraphSeries<DataPoint> series; //an Object of the PointsGraphSeries for plotting scatter graphs
graph = (GraphView) findViewById(R.id.graph);
series = new PointsGraphSeries<>(setData); //initializing/defining series to get the data from the method 'data()'
graph.addSeries(series); //adding the series to the GraphView
series.setShape(PointsGraphSeries.Shape.POINT);
series.setSize(6);
答案 0 :(得分:0)
在查找代码时,您会看到方法setData(字符串数据)但在series = new PointsGraphSeries<>(setData);
中您正在调用变量。请将setData(String data)方法的结果分配给局部变量,然后在提到的代码行中使用它。