1
我正在尝试制作具有多项选择的联系人选择器。我可以使用旁边的复选框加载所有联系人。但是,当我选择一个项目时,每个第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());
}
}