2012-08-07 45 views
0

我想用我的SQLite数据库中的数据在achartengine中构建一个图形。从数据库获取数据可行,但它始终只构建一个点而不是图。我究竟做错了什么?从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(); 
} 
} 

回答

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(); 
} 
} 
+0

AAAH你是最好的。它现在有效。 :) – JohnD 2012-08-07 13:31:33