如何从表中读出两列并对它们进行多重化?

时间:2012-02-07 15:27:04

标签: android sqlite add

我如何在Android Java中实现这一点? 所以我的意思是我如何读出标记和重量,将它们多重化并在同一系统中添加下一行?:

tbl_marks

这就是我现在用于列出ListView中的那些标记:

private void fillData() {

Bundle extras = getIntent().getExtras();
    String txt_sub_id = extras.getString("IDFach");
    int test = Integer.parseInt(txt_sub_id);

Cursor mCursor = db.rawQuery("SELECT _id, subid, name, mark, gewicht, datum FROM tbl_marks WHERE subid = '"+test+"';", null);
startManagingCursor(mCursor);
if (mCursor != null && mCursor.moveToFirst()) {
     int intName = mCursor.getColumnIndexOrThrow("subid");

      do {
          teststring = mCursor.getString(intName);

          String[] from = new String[] { dbHelper.KEY_NAME_MARKS, dbHelper.KEY_MARK_MARKS, dbHelper.KEY_GEWICHT_MARKS, dbHelper.KEY_DATUM_MARKS};
          int[] to = new int[] {R.id.txt_marks_row, R.id.txt_note, R.id.txt_gewicht, R.id.txt_datum};

          SimpleCursorAdapter notes = new SimpleCursorAdapter(this, R.layout.show_marks, mCursor, from, to);
          setListAdapter(notes);
      } while (mCursor.moveToNext());
}
    }

看起来像这样:

enter image description here

我喜欢什么:

enter image description here

提前致谢!

1 个答案:

答案 0 :(得分:1)

你需要在do / while循环中执行类似下面的操作。这里4是查询中列名的索引。

  int mark=mCursor.getInt(4);
   int wght=mCursor.getInt(5);