課程
/移動開發
/Android
/Android-節日短信送祝福(功能篇)
有沒有人遇到發送完短信切換到發送記錄就一直顯示一個progressBar,并沒有顯示發送記錄?
2015-12-28
源自:Android-節日短信送祝福(功能篇) 2-6
正在回答
1、確認是否寫入了數據庫,可以通過命令行看
2、數據寫入數據庫了,沒有顯示出來(也是我遇到的問題),原因是SmsProvider中的query寫錯了,正確的應該是:
@Nullable @Override public?Cursor?query(Uri?uri,?String[]?projection,?String?selection,?String[]?selectionArgs,?String?sortOrder)?{ ????int?match?=?matcher.match(uri); ????switch?(match)?{ ????????case?SMS_ALL: ????????????break; ????????case?SMS_ONE: ????????????long?id?=?ContentUris.parseId(uri); ????????????selection?=?"_id=?"; ????????????selectionArgs?=?new?String[]{String.valueOf(id)}; ????????????break; ????????default: ????????????throw?new?RSIllegalArgumentException("Wrong?URI:"?+?uri); ????} ????mDb?=?mHelper.getReadableDatabase(); ????Cursor?cursor?=?mDb.query(SendedMsg.TABLE_NAME,?projection,?selection,?selectionArgs,?null,?null,?sortOrder); ????cursor.setNotificationUri(getContext().getContentResolver(),?URI_SMS_ALL); ????//cursor.close(); ????return?cursor; }
注意最后兩行代碼
botao555 提問者
newView和bindView沒有被調用是為什么?
mCursorAdapter?=?new?CursorAdapter(getActivity(),?null,?false)?{ ????@Override ????public?View?newView(Context?context,?Cursor?cursor,?ViewGroup?parent)?{ ????????Log.e("CBT",?"newView-->"); ????????View?view?=?mInflater.inflate(R.layout.item_sended_msg,?parent,?false); ????????return?view; ????} ????@Override ????public?void?bindView(View?view,?Context?context,?Cursor?cursor)?{ ????????Log.e("CBT",?"bindView-->"); ????????TextView?msg?=?(TextView)?view.findViewById(R.id.id_tv_msg); ????????FlowLayout?fl?=?(FlowLayout)?view.findViewById(R.id.id_fl_contacts); ????????TextView?fes?=?(TextView)?view.findViewById(R.id.id_tv_fes); ????????TextView?date?=?(TextView)?view.findViewById(R.id.id_tv_date); ????????msg.setText(cursor.getString(cursor.getColumnIndex(SendedMsg.COLUMN_MSG))); ????????fes.setText(cursor.getString(cursor.getColumnIndex(SendedMsg.COLUMN_FES_NAME))); ????????date.setText(cursor.getString(cursor.getColumnIndex(SendedMsg.COLUMN_DATE))); ????????String?names?=?cursor.getString(cursor.getColumnIndex(SendedMsg.COLUMN_NAMES)); ????????Log.e("CBT","namesBefore-->"+names); ????????if?(TextUtils.isEmpty(names))?{ ????????????return; ????????} ????????Log.e("CBT","namesAfter-->"+names); ????????fl.removeAllViews(); ????????for?(String?name?:?names.split(":"))?{ ????????????addTag(name,fl); ????????} ????} };
舉報
本課程將帶領大家實現一個節日短信的應用,此課程為續集
1 回答數據庫保存不了,發送記錄沒有,請同學老師幫個忙看一下
1 回答發送短信的時候出錯了
1 回答節日短信送祝福
1 回答怎么給自己發短信?
1 回答關于ContentProvider中已經提供了獲取數據的方法,為什么在使用Loader加載的時候沒有使用到?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2016-02-20
1、確認是否寫入了數據庫,可以通過命令行看
2、數據寫入數據庫了,沒有顯示出來(也是我遇到的問題),原因是SmsProvider中的query寫錯了,正確的應該是:
注意最后兩行代碼
2015-12-28
newView和bindView沒有被調用是為什么?