0
想要使用模擬器中的聯繫人應用程序創建的聯繫人並顯示爲聯繫人列表 有什麼問題嗎?android聯繫人列表
佈局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Name: "
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/contact_name"/>
</LinearLayout>
碼
package fypj.e;
import android.app.ListActivity;
import android.database.Cursor;
import android.os.Bundle;
import android.provider.Contacts.People;
import android.provider.ContactsContract.CommonDataKinds.Phone;
import android.widget.*;
public class e extends ListActivity {
private SimpleCursorAdapter myAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//setContentView(R.layout.main);
Cursor cursor = getContentResolver().query(People.CONTENT_URI, null, null, null, null);
startManagingCursor(cursor);
String[] column = new String[] {Phone.LABEL};
int[] names = new int[] {R.id.contact_name};
myAdapter = new SimpleCursorAdapter(this, R.layout.main, cursor, column, names);
setListAdapter(myAdapter);
}
}
是用戶權限...閱讀內容...? – user669046 2011-03-24 04:50:45
沒有它的READ_CONTACTS http://developer.android.com/reference/android/Manifest.permission.html#READ_CONTACTS – the100rabh 2011-03-24 15:15:07
哦....我輸錯了 謝謝,我忘了屁股的使用權限 – user669046 2011-03-27 16:01:37