我正在尝试实现listview适配器,在适配器中我编写了这段代码
try {
dbhelper = new DBHelper(context);
database=dbhelper.getReadableDatabase();
String id = deviceid.toString().trim();
String query = ("select POND, MAXVALUE ,MINVALUE,MAXPHVALUE,MINPHVALUE from ponddata where POND ='" + id + "'");
cursor1 = database.rawQuery(query, null);
if(cursor1 != null){
if(cursor1.moveToLast()){
String maxvalue =cursor1.getString(cursor1.getColumnIndex("MAXVALUE"));
String minvalue =cursor1.getString(cursor1.getColumnIndex("MINVALUE"));
String maxphval = cursor1.getString(cursor1.getColumnIndex("MAXPHVALUE"));
String minphval = cursor1.getString(cursor1.getColumnIndex("MINPHVALUE"));
Float min = Float.parseFloat(minvalue);
Float max = Float.parseFloat(maxvalue);
ApplicationData.addmin(min);
ApplicationData.addmax(max);
Float min1=Float.parseFloat(minphval);
Float max1=Float.parseFloat(maxphval);
ApplicationData.addmin1(min1);
ApplicationData.addmax1(max1);
}
cursor1.moveToNext();
}
} finally {
cursor1.close();
database.close();
}
但它在cursor1.closse()database.close()中显示错误。 像致命的例外 处理com.eample.test过程:PID 11536 null指针在adapter.getView上的异常。 请任何人帮忙,为什么它显示错误。我试图从早上解决这个错误。请帮忙。