无法显示发送记录
有没有人遇到发送完短信切换到发送记录就一直显示一个progressBar,并没有显示发送记录?
有没有人遇到发送完短信切换到发送记录就一直显示一个progressBar,并没有显示发送记录?
2015-12-28
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; }
注意最后两行代码
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); } } };
举报