Android日期分组,按查询分组在列表视图android中显示一些意...
我有一個列表視圖,其中顯示了從聯系人號碼收到的消息.現在的問題是,如果我收到來自“ 1234567”的5條消息和來自“ 56789”的3條消息,那么我的主列表視圖顯示了8條消息,盡管我只想在我的主要lisvtiew中通過這兩個數字顯示1條消息,類似于sms應用程序作為線程并在項目上單擊,將顯示該特定編號的剩余消息.
有人回答我使用按電話號碼分組查詢來按電話號碼查詢結果.
當收到任何短信時,我將其保存在名為“ smss”的表中.
這是我從數據庫中獲取數據時的代碼:
public ArrayList fetchScreenedSms() {
Sms a = new Sms();
ArrayList smsInbox = new ArrayList();
String query_fetchSMS = "select * from " + "smss" + " group by " + "contactnumber" + "\"" ;
DBtableforNotSpam smsD = new DBtableforNotSpam(this);
SQLiteDatabase dbw = smsD.getWritableDatabase();
Cursor cursor = dbw.rawQuery(query_fetchSMS, null);
if (cursor != null) {
cursor.moveToLast();
if (cursor.getCount() > 0) {
do {
Sms message = new Sms();
message.id = cursor.getInt(cursor
.getColumnIndex("id"));
message.messageNumber = cursor.getString(cursor
.getColumnIndex("contactnumber"));
message.messageSender = cursor.getString(cursor
.getColumnIndex("contactname"));
message.messageContent = cursor.getString(cursor
.getColumnIndex("message"));
message.setDate(cursor.getString(cursor
.getColumnIndex("date")));
smsInbox.add(message);
} while (cursor.moveToPrevious());
} else {
empty.setVisibility(View.VISIBLE);
}
這是我在數據庫中保存短信的代碼:
public void screenMessagee(Context context, String msg_from, String msgSender,
String msgBody, String msgDate) {
DBtableforNotSpam smsdb = new DBtableforNotSpam(context);
SQLiteDatabase dbw = smsdb.getWritableDatabase();
String query_insertSMS = "insert into " + "smss" + "(" + "contactnumber" + "," + "contactname" + "," + "message"
+ "," + "date" + ") values (\"" + msg_from.toString() + "\", \"" + msgSender + "\",\"" + msgBody
+ "\",\"" + msgDate + "\")";
dbw.execSQL(query_insertSMS);
smsdb.close();
dbw.close();
abortBroadcast();
}
現在我在某人建議的fetchScreenSms方法中應用了按組查詢,但是如果應用了此方法,則listview沒有顯示任何內容,即它為空的listview數據:
String query_fetchSMS = "select * from " + "smss" + " group by " + "contactnumber" + " = \"" + "\"" ;
這是某人建議的,但在列表視圖中什么也沒有顯示
當我應用此然后listview顯示與該數字有關的數據.
String query_fetchSMS = "select * from " + "smss" + " group by " + "contactnumber" + " = \"" + "1234567" + "\"" ;
在查詢之后,列表視圖在我的主列表視圖中向我顯示該編號中的一條消息,然后在其中顯示5條消息.這正是我想要的.但是為什么上層查詢不起作用?我想同時顯示兩個數字消息
問題在什么地方發生?
使用簡單的分組查詢時不顯示結果,但在分組依據中指定數字時顯示結果.
任何人都可以幫助Iam卡住
總結
以上是生活随笔為你收集整理的Android日期分组,按查询分组在列表视图android中显示一些意...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: linkstack头文件 c语言,链式栈
- 下一篇: mi2 android 5.0 方法,小