1
在我的android應用程序中,我有一個ExpandableListView,每個組只有一個子項,其中包含一個複選框。我在設置複選框的值時遇到問題。ExpandViewListView的ChildView中的複選框
我從數據庫中檢索複選框的值,它在一個整數的ArrayList與值檢查,未經檢查分別
ArrayList<Integer> trustedList = new ArrayList<Integer>();
起初,我已經把所有的條目在數據庫中存儲0 & 1爲1.
爲ExpandableListView適配器類如下:
class DataAdapter extends BaseExpandableListAdapter {
private Context context;
LayoutInflater lat = getLayoutInflater();
CheckBox cb;
public DataAdapter(Context context) {
// TODO Auto-generated constructor stub
this.context = context;
}
@Override
public View getChildView(int group, int child, boolean arg2, View v,
ViewGroup arg4) {
// TODO Auto-generated method stub
v = lat.inflate(R.layout.inflate_list, null);
cb = (CheckBox) v.findViewById(R.id.checkBox1);
if (trustedList.get(group) == 1)
cb.setChecked(true);
else
cb.setChecked(false);
return v;
}
}
但我發現了未經檢查的數值F或複選框。此外,在檢查複選框並摺疊和擴展組時,我會再次取消選中複選框。
請有人可以幫助我?
感謝羅希特...而且順便說一句,我也發現了該問題的其他解決辦法,但你是短ň甜...謝謝 –
嗨,當我使用此代碼的複選框 - 有剛CompoundButton.OnCheckedChangeListener但我有一個複選框 - –