我正在尝试使用我的SQLite数据库中的数据在achartengine
中构建一个图表。从数据库中获取数据是有效的,但它始终只构建一个点,而不是图形。我做错了什么?
这是我的代码:
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();
}
}
答案 0 :(得分: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();
}
}