Android SDK中带有复选框的自定义Listview

Android SDK中带有复选框的自定义Listview,android,listview,checkbox,Android,Listview,Checkbox,嗨,我是Android开发新手, 如何在Android SDK中显示带有复选框的自定义Listview。“我需要选中”复选框应在不需要选择之前选中 例如,我有一个favarote视图,我以前选择的一些项目在我必须转到该视图时应显示为已选择 请任何人帮助我 提前感谢private void SaveSelections(){ private void SaveSelections() { // save the selections in the shared preference in

嗨,我是Android开发新手, 如何在Android SDK中显示带有复选框的自定义Listview。“我需要选中”复选框应在不需要选择之前选中

例如,我有一个favarote视图,我以前选择的一些项目在我必须转到该视图时应显示为已选择

请任何人帮助我

提前感谢

private void SaveSelections(){
private void SaveSelections() {

    // save the selections in the shared preference in private mode for the
    // user

    SharedPreferences settingsActivity = getPreferences(MODE_PRIVATE);
    SharedPreferences.Editor prefEditor = settingsActivity.edit();

    savedNames = getSavedItems();

    prefEditor.putString(SETTING_TODOLIST, savedNames);

    prefEditor.commit();
}

private String getSavedItems() {
    String savedNames = "";

    int count = this.listView.getAdapter().getCount();

    for (int i = 0; i < count; i++) {

        if (FPhoneListCheckboxAES.phonelist.get(i).getChecked() == true) {

            if (savedNames.length() > 0) {
                savedNames += ","
                        + FPhoneListCheckboxAES.phonelist.get(i).getname();
                savedPhoneno += ","
                        + FPhoneListCheckboxAES.phonelist.get(i).getphoneNo();

            } else {
                savedNames += FPhoneListCheckboxAES.phonelist.get(i).getname();
                savedPhoneno += FPhoneListCheckboxAES.phonelist.get(i)
                        .getphoneNo();

            }
        }

    }
    return savedNames;
}
//以专用模式将选择保存在共享首选项中,以用于 //使用者 SharedReferences settingsActivity=getPreferences(模式\私人); SharedReferences.Editor prefEditor=settingsActivity.edit(); savedNames=getSavedItems(); prefEditor.putString(设置_TODOLIST,savedNames); 提交(); } 私有字符串getSavedItems(){ 字符串savedNames=“”; int count=this.listView.getAdapter().getCount(); for(int i=0;i0){ savedNames+=“,” +FPhoneListCheckboxAES.phonelist.get(i).getname(); savedPhoneno+=“,” +FPhoneListCheckboxAES.phonelist.get(i).getphoneNo(); }否则{ savedNames+=FPhoneListCheckboxAES.phonelist.get(i).getname(); savedPhoneno+=FPhoneListCheckboxAES.phonelist.get(i) .getphoneNo(); } } } 返回保存的名称; }
检查链接这将帮助你很多


您所说的“我需要选中”是什么意思?在不需要选择之前,应选中复选框。我的意思是,我在listview中显示了10项。我需要选中我以前选中的复选框3。