複数選択で連絡先ピッカーを作成しようとしています。横にチェックボックスがあるすべての連絡先を読み込むことができます。ただし、アイテムを選択すると、リスト内の 8 番目のアイテムが自動的に選択されます。さらに、上下にスクロールすると、すべての選択が自動的に変更されます。
これの何が悪いのか誰か知っていますか?これが私の連絡先ピッカークラスです
public class HomeActivity extends ListActivity {
public void onCreate(Bundle paramBundle) {
super.onCreate(paramBundle);
Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI,null, null, null, null);
SimpleCursorAdapter adapter = new SimpleCursorAdapter(this,
android.R.layout.simple_list_item_multiple_choice,
cursor,
new String[] {ContactsContract.Contacts.DISPLAY_NAME},
new int[] { android.R.id.text1},0);
setListAdapter(adapter);
}
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
CheckedTextView textView = (CheckedTextView)v;
textView.setChecked(!textView.isChecked());
}
}