我想为折线图制作图表。所以我引用了achartEngine,这是我的代码:
int[] x = {1, 2, 3, 4, 5};
int[] y = {24, 33, 15, 20, 55};
TimeSeries serial = new TimeSeries("Line 1");
for (int i = 0 ; i < x.length ; i++) {
serial.add(x[i], y[i]);
}
XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();
dataset.addSeries(serial);
到目前为止毫无疑问,但我不知道如何用int替换数组。
例如,我使用sqlite:
SQLiteDatabase db = dbhelper.getReadableDatabase();
String[] columns = {KEY_ID, TEMPER};
Cursor cursor = db.query(TABLE_NAME, null, null);
int id = cursor.getColumnIndex(KEY_ID);
int ect = cursor.getColumnIndex(TEMPER);
我处于这种情况,对我有什么建议吗?
答案 0 :(得分:0)
你不需要阵列。无论您在何处使用它,请将其替换为从光标读取的值:
int id = cursor.getColumnIndexOrThrow(KEY_ID);
int ect = cursor.getColumnIndexOrThrow(TEMPER);
while (cursor.moveToNext()) {
serial.add(cursor.getInt(id), cursor.getInt(ect));
}