2012-08-07 67 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