慕娘0097699
2017-09-18 19:03
按着视频写出来我为什么会出现闪退呢
我遇到的问题是costBean.costMoney = cursor.getString (cursor.getColumnIndex ("cost_Money"));
这行代码有问题。 cursor.getColumnIndex ("cost_Money")得到的返回值是-1,然后得不到getString的返回值。返回错误,造成程序闪退。因为数据库中,money的column比data的column多1然后我就改写了一下,绕过了这个问题。int datacolumnIndex = cursor.getColumnIndex ("cost_date");
costBean.costMoney = cursor.getString(datacolumnIndex+1);
这样的话就不存在找不到money的column了,用data的column+1代表money。顺利解决。
是不是编译过后 初始化布局的时候,从数据库读取数据cost_data出现错误,我的也是。暂时还没有找到答案,找到了再来告诉你。
Android记账本
18788 学习 · 58 问题
相似问题