0

我正在尝试achartengine使用我的 SQLite 数据库中的数据构建一个图表。从数据库中获取数据是可行的,但它总是只构建一个点而不是图形。我究竟做错了什么?

这是我的代码:

public String getValue1(long l) {
String[] columns = new String[]{ KEY_Value1, KEY_Value2 };
Cursor c = Database.query(DATABASE_TABLE, columns, KEY_ROWID + "=" + l, null, null, null, null);
if (c != null){
c.moveToFirst();
String value1 = c.getString(0);
return value1;
}
return null;
}

public String getValue2(long l) {
String[] columns = new String[]{ KEY_Value1, KEY_Value2 };
Cursor c = Database.query(DATABASE_TABLE, columns, KEY_ROWID + "=" + l, null, null, null, null);
if (c != null){
c.moveToFirst();
String value2 = c.getString(1);
return value2;
}
return null;
}

DB getData = new DB(this);
getData.open();
for (int i = 1; value1 == null; i++) {
Stirng value1 = getData.getValue1(i);
String value2 = getData.getValue2(i);
}
getData.close();

x = Double.parseDouble(value1);
y = Double.parseDouble(value2);

mCurrentSeries.add(x, y);

if (mChartView != null) {
mChartView.repaint();
}
}
4

1 回答 1

1

编辑此代码的第二部分:

DB getData = new DB(this);
getData.open();
for (int i = 1; value1 == null; i++) {
String value1 = getData.getValue1(i);
String value2 = getData.getValue2(i);

x = Double.parseDouble(value1);
y = Double.parseDouble(value2);

mCurrentSeries.add(x, y); //*** this has to be inside the loop in order to draw more than one point ***

}
getData.close();

if (mChartView != null) {
mChartView.repaint();
}
}
于 2012-08-07T13:24:21.030 回答