課程
/移動開發(fā)
/Android
/Android記賬本
有沒有同學(xué)用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的準(zhǔn)確列數(shù),所以需要改成如下形式。
????????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為基準(zhǔn)列數(shù),向后退出cost_date和cost_money的列數(shù)。
舉報
本課程是一個案例課程,主要講解第三方庫圖標(biāo)和數(shù)據(jù)庫的結(jié)合使用
1 回答APP做完后閃退
2 回答求救 怎么就閃退了
1 回答為什么閃退?
3 回答輸入就閃退
1 回答這個問題怎么解決,只知道是順序問題,剛學(xué)還不懂怎么解決,???
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習(xí)伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
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的準(zhǔn)確列數(shù),所以需要改成如下形式。
????????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為基準(zhǔn)列數(shù),向后退出cost_date和cost_money的列數(shù)。