如何选中和取消选中复选框?

时间:2015-05-21 02:24:43

标签: android json dynamic checkbox sharedpreferences

我正在创建一个涉及XAMPP和JSON的清单。作为将Checkbox状态保存到sharedPreferences之前的第一步,有人可以帮助我检查/取消选中UISaveVideoAtPathToSavedPhotosAlbum中的复选框吗?我在PHPhotoLibrary.sharedPhotoLibrary().performChanges({ PHAssetChangeRequest.creationRequestForAssetFromVideoAtFileURL(f) }, completionHandler: { (ok:Bool, err:NSError!) in // whatever }) 中使用SimpleAdapter,因此我不知道如何选中/取消选中复选框。我发现的所有示例都经常使用setOnItemClickListener和自定义适配器。我无法覆盖SimpleAdapter的onPostExecute

我的AllDetails类扩展了ListActivity。

viewHolder

我的JSON部分

getView

1 个答案:

答案 0 :(得分:0)

link将指导您从自定义适配器获取复选框值并保存到共享首选项。修改此代码以从json

提供信息
ArrayList<Country> countryList = new ArrayList<Country>();
Country country = new Country("AFG","Afghanistan",false);
countryList.add(country);
...

使用您的产品列表并传递给自定义适配器

//create an ArrayAdaptar from the String Array
dataAdapter = new MyCustomAdapter(this,
R.layout.country_info, countryList);
ListView listView = (ListView) findViewById(R.id.listView1);
// Assign adapter to ListView
listView.setAdapter(dataAdapter);

在您的onPostExecute()中并更改checkButtonClick()以保存您在dataAdapter中的共享偏好