我想在textview中反向显示SQLite中的行数据,例如,如果我的行是: " A"," B"," C"," D"," E" 我想表明: " E"," D"," C"," B"," A"
这是我的代码:
Cursor c = myDB.rawQuery("SELECT * FROM mydataBase", null);
int rows = c.getCount();
int cols = c.getColumnCount();
c.moveToFirst();
// outer for loop
for (int i = 0; i < rows; i++) {
TextView myTableRowTextView = new TextView(this);
TableRow row = new TableRow(this);
// inner for loop
for (int j = 0; j < cols; j++) {
myTableRowTextView = new TextView(this);
myTableRowTextView.setGravity(Gravity.CENTER);
myTableRowTextView.setTextSize(18);
Cursor cc = myDB.rawQuery("SELECT * FROM myDataBase", null);
myTableRowTextView.setText(c.getString(j));
row.addView(myTableRowTextView);
}
c.moveToNext();
myTableLayout.addView(row);
}
问题在于:myTableRowTextView.setText(c.getString(j)); 在textView中显示我的行,有人可以帮我吗?
答案 0 :(得分:0)
您可以使用其他方式列出所有列
for (int j = cols -1; j > -1; j--) {
myTableRowTextView = new TextView(this);
myTableRowTextView.setGravity(Gravity.CENTER);
myTableRowTextView.setTextSize(18);
Cursor cc = myDB.rawQuery("SELECT * FROM myDataBase", null);
myTableRowTextView.setText(c.getString(j));
row.addView(myTableRowTextView);
}