我在数据库中有标记和类现在我想创建textviews动态地将数据库中的结果设置为textview我可以这样做吗
private void displaymarks() {
// TODO Auto-generated method stub
Cursor c=marksdb.rawQuery("SELECT class,marks FROM markstb where class='"+clas+"' ",null );
c.moveToFirst();
if(c!=null)
{
do{
int c1= c.getColumnIndex("class");
int c2=c.getColumnIndex("marks");
s1 = c.getString(c1);
s2 = c.getString(c2);
}while(c.moveToNext());
};
}
答案 0 :(得分:0)
TextView tvClass=(TextView)findViewById(R.id.class);
TextView tvMarks=(TextView)findViewById(R.id.marks);
while(c.moveToNext())
{
tvClass.setText(s1);
tvMarks.setText(s2);
}