从sum函数中获取我的光标

时间:2012-10-17 04:22:00

标签: android cursor adapter textview

这是我获取查询的功能:

public Cursor getSaldo(String id) {
        String[] args={id};
        return(getReadableDatabase()
        .rawQuery("SELECT sum("+t_jumlah+") "+
                "as "+t_saldo+" "+
                "FROM "+t_table+" WHERE "+t_nId+"=?", args));

如何将数据放入我的TextView

我有这样的光标

almagId=getIntent().getStringExtra(Nasabah.ID_EXTRA);

Cursor c=helper.getSaldo(almagId);
startManagingCursor(c);

1 个答案:

答案 0 :(得分:0)

你可能会做这样的事情。试试吧

 if(!cursor.moveToFirst()){
 mytextView.setText("No output");
}
else{
do {
mytextView.setText(cursor.getString(0)); 

} while (cursor.moveToNext());