/** * initial adapter first step: get part of data (model) second step: build a new adapter and * initial it (controller) third step: set adapter for ListView (view) */ private void initAdapter() { if (listView == null) return; batchLocalData(); adapter = new CommonListAdapter(); adapter.setContext(this); adapter.setData(adapterData); adapter.setFullChecked(false); // restore checkBox to default state checkBox.setChecked(false); // addHeaderView or addFooterView has to be called before setAdapter listView.addHeaderView(header, "header", false); listView.setAdapter(adapter); }
/** bind onClickListener for checkBox set full-checked state */ public void onCheckboxClicked(View view) { if (checkBox.isChecked()) { ToastUtil.showToast(this, checkBox.isChecked() + ""); for (GoodsInformation singleData : adapterData) { singleData.setSelected(true); } adapter.setFullChecked(true); adapter.notifyDataSetChanged(); } else { ToastUtil.showToast(this, checkBox.isChecked() + ""); for (GoodsInformation singleData : adapterData) { singleData.setSelected(false); } adapter.setFullChecked(false); adapter.notifyDataSetChanged(); } }