我正在构建一个 Android 应用程序。我正在使用 Sqlite 数据库、四个单选按钮和一个文本视图。当我单击每个单选按钮时,它应该显示数据库中的下一组数据。现在,它只显示数据库中的第一个数据行。如何更改我的代码以使其显示适当的行?
编码
db.open();
try{
final Cursor c = db.getAllQue();
if(c != null)
{
if (c.moveToFirst())
{
int size = c.getCount();
for(int i=0;i<=size;i++)
quen = (TextView) findViewById(R.id.textView1);
anss1 = (RadioButton) findViewById(R.id.radio0);
anss2 = (RadioButton) findViewById(R.id.radio1);
anss3 = (RadioButton) findViewById(R.id.radio2);
anss4 = (RadioButton) findViewById(R.id.radio3);
rgp1 = (RadioGroup) findViewById(R.id.radioGroup1);
String ques = c.getString(0);
String anes1 = c.getString(1);
String anes2 = c.getString(2);
String anes3 = c.getString(3);
String anes4 = c.getString(4);
String anes = c.getString(5);
rgp1.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(RadioGroup group, int checkedId) {
RadioButton radioButton = (RadioButton) findViewById(checkedId);
Toast.makeText(SqlliteActivity.this, "" + radioButton.getText(), 2000).show();
c.moveToNext();
}
});
quen.setText(ques);
anss1.setText(anes1);
anss2.setText(anes2);
anss3.setText(anes3);
anss4.setText(anes4);
}
}
}catch(Exception e){
System.out.println(e);
}
db.close();
}