課程
/移動開發
/Android
/Android記賬本
有沒有同學用Android Studio 3.0 做的?運行之后老是閃退,怎么解決?
2017-12-06
源自:Android記賬本 2-1
正在回答
厲害啦
你是真的牛逼
解決了。
有兩個地方需要改。
?public Cursor getAllCostData() { ? ?SQLiteDatabase database = getWritableDatabase(); ? ?return database.query("imooc_daily", null, null, null, null, null, "cost_date" +"ASC");}最后面的排序需要改成 "cost_date ASC"
if (cursor != null) { ? ?while (cursor.moveToNext()) { ? ? ? ?CostBean costBean = new CostBean(); ? ? ? ?costBean.costTitle = cursor.getString(cursor.getColumnIndex("cost_title")); ? ? ? ?costBean.costDate = cursor.getString(cursor.getColumnIndex("cost_date")); ? ? ? ?costBean.costMoney = cursor.getString(cursor.getColumnIndex("cost_money")); ? ? ? ?mCostBeanList.add(costBean); ? ?} ? ?cursor.close();}這里獲取不了cost_money的準確列數,所以需要改成如下形式。
????????if (cursor != null) { ? ?while (cursor.moveToNext()) { ? ? ? ?CostBean costBean = new CostBean(); ? ? ? ?int dataColumnIndex = cursor.getColumnIndex("cost_title"); ? ? ? ?costBean.costTitle = cursor.getString(dataColumnIndex + 0); ? ? ? ?costBean.costDate = cursor.getString(dataColumnIndex + 1); ? ? ? ?costBean.costMoney = cursor.getString(dataColumnIndex + 2); ? ? ? ?mCostBeanList.add(costBean); ? ?} ? ?cursor.close();}這里是以cost_title為基準列數,向后退出cost_date和cost_money的列數。
舉報
本課程是一個案例課程,主要講解第三方庫圖標和數據庫的結合使用
1 回答APP做完后閃退
2 回答求救 怎么就閃退了
1 回答為什么閃退?
3 回答輸入就閃退
2 回答一輸入就閃退
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2021-01-02
厲害啦
2017-12-25
你是真的牛逼
2017-12-06
解決了。
有兩個地方需要改。
?public Cursor getAllCostData() {
? ?SQLiteDatabase database = getWritableDatabase();
? ?return database.query("imooc_daily", null, null, null, null, null, "cost_date" +"ASC");
}最后面的排序需要改成 "cost_date ASC"
if (cursor != null) {
? ?while (cursor.moveToNext()) {
? ? ? ?CostBean costBean = new CostBean();
? ? ? ?costBean.costTitle = cursor.getString(cursor.getColumnIndex("cost_title"));
? ? ? ?costBean.costDate = cursor.getString(cursor.getColumnIndex("cost_date"));
? ? ? ?costBean.costMoney = cursor.getString(cursor.getColumnIndex("cost_money"));
? ? ? ?mCostBeanList.add(costBean);
? ?}
? ?cursor.close();
}這里獲取不了cost_money的準確列數,所以需要改成如下形式。
????????if (cursor != null) {
? ?while (cursor.moveToNext()) {
? ? ? ?CostBean costBean = new CostBean();
? ? ? ?int dataColumnIndex = cursor.getColumnIndex("cost_title");
? ? ? ?costBean.costTitle = cursor.getString(dataColumnIndex + 0);
? ? ? ?costBean.costDate = cursor.getString(dataColumnIndex + 1);
? ? ? ?costBean.costMoney = cursor.getString(dataColumnIndex + 2);
? ? ? ?mCostBeanList.add(costBean);
? ?}
? ?cursor.close();
}這里是以cost_title為基準列數,向后退出cost_date和cost_money的列數。