0

在使用 TextView 显示消息时抛出一个致命错误。我正在使用这个程序我也设置了一些记录器。它运行良好,直到 logger="lastmark"。

        private void displayText(String message){
        logger.info("inside display message");
        TextView textView = (TextView)findViewById(R.id.name_1);
        logger.info("last mark");
        textView.setText(message);

    }
    public void callStatus(){

        logger.info("inside 3 rd step");
        dataBase = DataBaseManager.instance();

        logger.info("inside 4 rd step");
        //to get data from database we need a cursor.
        //after we perform a select query all the data from database specific for the query, will be in the cursor
        // "*" means "all" in translation the query means "SELECT ALL FROM NAME TABLE"

        cursor = dataBase.select("SELECT * FROM " + TABLE_NAME);
        logger.info("inside 4b rd step");
        String s ="";
        logger.info("inside 5 rd step");

        //the cursor iterates the column "name"
        while (cursor.moveToNext()){
            do{


            //in this string we get the record for each row from the column "name"
            logger.info("inside 6 rd step");
            String s1 = cursor.getString(cursor.getColumnIndex(COLUMN_NAME1));
            String s2 = cursor.getString(cursor.getColumnIndex(COLUMN_NAME2));
            s = s1+s2;
            }while  (cursor.moveToNext());
            logger.info("inside 7 rd step");
            //in this textView will be added, updated or deleted the string
            // "\n" means "new line"
        }

        //here we close the cursor because we do not longer need it
        cursor.close();
        logger.info("inside 8 rd step");
        displayText(s);
    }


}

....在使用 TextView 显示消息时抛出一个致命错误。我正在使用这个程序,我也设置了一些 looger。它运行良好,直到 logger="lastmark"。

4

2 回答 2

1

尝试这个:

创建光标后

if (cursor.moveToFirst())
{
    do
    {
       // get column1 and column2 
       ....
    } while (cursor.moveToNext())
}

并确保在所有游标操作后关闭游标。

于 2013-08-19T01:58:52.270 回答
0

我知道,在 while (cursor.moveToNext()){……} 之前,你应该先将光标移动到第一个
cursor.moveToFirst() 必须先执行!

于 2013-08-19T02:02:11.597 回答