我有以下代碼:如何正確顯示傳入的SMS發件人和日期?
Uri uriSMS = Uri.parse("content://sms");
Cursor cur = getContentResolver().query(uriSMS,
new String[] {"_id", "thread_id", "address", "person", "date", "body", "type"},
null, null, null);
startManagingCursor(cur);
String[] from = new String[]{"address", "body", "date"};
int[] to = new int[]{R.id.sms_from, R.id.sms_body, R.id.sms_date};
adapter = new SimpleCursorAdapter(this, R.layout.sms_row, cur, from, to);
setListAdapter(adapter);
目前我使用address
列中顯示SMS發送器,從而顯示電話號碼。我想用人名替換電話號碼。我期望person
包含它,但它對於大多數SMS是空的。 然後,date
字段包含long
的值,當我想以DD.MM.YYYY
的格式顯示它時。我想我可以覆蓋setViewValue()
來修復它。但有沒有其他(更好的)解決方案&
我該如何解決這兩個問題?
謝謝。你的回覆沒有完全回答我的問題。所以,我已經用'setViewValue()'完成了我所需要的工作,但是你的回答很有幫助,所以我接受它。謝謝。 –