在我的代码中,我正在listview
向我的应用程序提取收件箱邮件我想要的是我提供show view
作为option menu
项目来更改数据{{1}将显示ie(1)第一个视图是listview
(2)All inbox messages will be displayed
但是当我正在运行我的应用程序时,列表视图中没有显示任何内容。
谁能告诉我怎么做......
only messages from unknown no's will be displayed
选项菜单中的代码:
public void getInboxSms() {
ContentResolver cr = getContentResolver();
c = cr.query(Uri.parse("content://sms/inbox"), null, null, null, null);
totalSMS = c.getCount();
if (c.moveToFirst()) {
for (int i = 0; i < totalSMS; i++) {
Log.d("SMSss", "Contact number : "+ c.getString(c.getColumnIndexOrThrow("address"))+ "\n"
+ "msg : " + c.getColumnIndexOrThrow("body")
+ "\n"
+ "Person : "
+ getContactName(c.getString(c.getColumnIndexOrThrow("address"))));
c.moveToNext();
}
}
}
public String getContactName(String phoneNumber) {
ContentResolver cr = getApplicationContext().getContentResolver();
Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI,
Uri.encode(phoneNumber));
Cursor cursor = cr.query(uri,
new String[] { PhoneLookup.DISPLAY_NAME }, null, null, null);
if (cursor == null) {
return null;
}
String contactName = null;
if (cursor.moveToFirst()) {
contactName = cursor.getString(cursor
.getColumnIndex(PhoneLookup.DISPLAY_NAME));
}
if (cursor != null && !cursor.isClosed()) {
cursor.close();
}
return contactName;
}
private List<SMSListModel> getModel()
{
if(c.getCount()>0)
{
for(int i=0;i<c.getCount();i++)
{
if(c.moveToPosition(i))
{
if(getContactName(c.getString(c.getColumnIndex("address"))) == null ){
list.add(new SMSListModel(c.getString(c.getColumnIndex("address")),c.getString(c.getColumnIndex("body"))));
}
}
}
}
return list;
}
答案 0 :(得分:0)
您是否检查过Select_view数组在创建Dialog时是否有值?