2
我试图从CALL-LOGS
这是在我的联系人不得到所有号码的清单,通话记录没有得到CACHED_NAME
我面临的issue
当任何人谁是我的联系人打电话给我。
光标“Ç”返回了号码,因为“name
‘(CACHED_NAME
)是null
’。
但是当我打开call-log
应用程序,然后再次打开我的application
,该号码将不会返回现在“” 名 “(CACHED_NAME
)” 具有价值。
我能刷新从我的应用程序呼叫日志数据?
我可以建立一个function
,它可以检查电话联系中是否存在号码。
但我该如何使用这个函数与光标适配器。我试图在bindview中使用这个函数,但仍然为该数字创建了空白元素。我想使用CusrorAdapter
。
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
pview = inflater.inflate(R.layout.fragment_call, container, false);
ListView lvCall = (ListView) pview.findViewById(R.id.lvCall);
Uri uri = Uri.parse("content://call_log/calls");
ContentResolver cr = getActivity().getContentResolver();
**Cursor c = cr.query(uri, null, "name is null", null, "date DESC");**
adapter = new CursorAdapter(getActivity().getBaseContext(), c) {
@Override
public View newView(Context context, Cursor cursor, ViewGroup parent) {
LayoutInflater li = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
return li.inflate(R.layout.call_list, parent, false);
}
@Override
public void bindView(View view, Context context, Cursor cursor) {
**if (contactExists(cursor.getString(cursor.getColumnIndex("NUMBER")))) {
return;
}**
txt_call_number = (TextView) view.findViewById(R.id.txt_call_number);
txt_call_id = (TextView) view.findViewById(R.id.txt_call_id);
txt_call_number.setText(cursor.getString(cursor.getColumnIndex("NUMBER")));
txt_call_id.setText(cursor.getString(cursor.getColumnIndex("_ID")).trim());
}
};
lvCall.setAdapter(adapter);
return pview;
}
感谢
附:以上示例代码中可能有一些技术error
或missing code
,因为我刚刚从我的application
中提取了所需的code
。
是的。这将工作。但我想以其他方式做....不是通过设置可视性。 – Maulik