【发布时间】:2015-09-01 16:01:32
【问题描述】:
我的班级有一个ListView,我有一个关于数字x 的光标,它每次都在递增,我在ListView 中使用这个光标,但当时我正在使用这个@987654324 @ListView 中仅显示一行。我想显示有关递增值的所有列表。我的代码如下:
if (cursor.moveToFirst()) {
do {
do {
int x = cursor.getInt(cursor.getColumnIndex("trainId"));
String s1 = "SELECT * FROM route_table WHERE trainId=" + x + " AND stationId=" + FromStationId + ";";
String s2 = "SELECT * FROM route_table WHERE trainId=" + x + " AND stationId=" + ToStationId + ";";
final Cursor c1 = SQ.rawQuery(s1, null);
final Cursor c2 = SQ.rawQuery(s2, null);
if (c1 != null && c1.moveToFirst()) {
i = c1.getInt(c1.getColumnIndex("_id"));
c1.close();
}
if (c2 != null && c2.moveToFirst()) {
j = c2.getInt(c2.getColumnIndex("_id"));
c2.close();
}
if (i < j) {
Toast.makeText(this, "My Train is:" + x, Toast.LENGTH_SHORT).show();
String fstring = "SELECT * FROM train_table WHERE _id=" + x + ";";
final Cursor c3 = SQ.rawQuery(fstring, null);
final ListView lv = (ListView) findViewById(R.id.tiimetable_list);
CursorAdapterTimeTable myc = new CursorAdapterTimeTable(this, c3);
lv.setAdapter(myc);
// List(x);
}
break;
} while (cursor.moveToNext());
continue;
} while (cursor.moveToNext());
【问题讨论】:
-
查询中的X是递增的。
标签: android android-listview android-sqlite