안녕하세요 저는 기본적으로 전화 연락처 목록을 채우고 목록보기에 표시하는 다음 코드를 가지고 있습니다.채워진 목록보기에서 전화 번호부 연락처 선택
listView = (ListView) layout.findViewById(R.id.listView);
// GET PHONE BOOK'S CONTENT
cursor = getContentResolver().query(
ContactsContract.CommonDataKinds.Phone.CONTENT_URI,
null,
null,
null,
null);
startManagingCursor(cursor);
String [] entries = {
ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER,
ContactsContract.CommonDataKinds.Phone._ID
};
int [] temp = {
android.R.id.text1,
android.R.id.text2
};
SimpleCursorAdapter listAdapter = new SimpleCursorAdapter(mContext,
android.R.layout.simple_list_item_2,
cursor, entries, temp);
listView.setAdapter(listAdapter);
if(listView != null){
listView.setOnItemClickListener(new OnItemClickListener(){
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id) {
// TODO Auto-generated method stub
Log.w("TAG", "SELECTING: " + listView.getAdapter().getItem(position).toString());
/*
Intent i = new Intent(android.content.Intent.ACTION_VIEW,
Uri.fromParts("sms", listView.getAdapter().getItem(position).toString(), null));
i.putExtra("sms_body", "Some message goes here.");
i.setType("vnd.android-dir/mms-sms");
startActivity(i);
*/
}
});
}
내가하고 싶은 것은 연결된 전화 번호 (기본 전화 번호)와 함께 연락처의 이름을 출력하는 것입니다. 그래서 나는 SMS 문자 메시지가 전화 번호와 내 연락처의 이름을 기반으로 미리 정의 된 새로운 의도를 만들 수 있습니다.
아무에게도 어떻게 할 수 있습니까? 감사합니다
고마워요,하지만 제 말은 당신이 오해 한 것 같아요. 목록보기에서 클릭 한 항목의 이름과 전화 번호를 출력 (즉 Logcat에 표시)하려고합니다. – Jeremy
코드를 지금 확인하십시오.이 코드가 도움이되기를 바랍니다. –