@Override public View getChildView(int i, final int i2, boolean b, View view, ViewGroup viewGroup) { SharedPreferences sharedPreferences = context.getSharedPreferences( SettingStrings.shared_user_settings + LinkBoxController.usrListData.usrKey, 0); final SharedPreferences.Editor editor = sharedPreferences.edit(); if (view == null) { view = layoutInflater.inflate(R.layout.layout_notification_list_item, viewGroup, false); } BoxListData boxListData = getChild(i, i2); TextView tvChildNotification = ViewHolder.get(view, R.id.TV_child_notification_user_setting); CheckBox cbChildNotification = ViewHolder.get(view, R.id.CB_child_notification_user_setting); tvChildNotification.setText(boxListData.boxName); cbChildNotification.setEnabled(LinkBoxController.defaultAlarm); cbChildNotification.setChecked(sharedPreferences.getBoolean("notiCheck" + i2, true)); Log.d(TAG, boxListData.boxName + " : " + sharedPreferences.getBoolean("notiCheck" + i2, true)); cbChildNotification.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { editor.putBoolean("notiCheck" + i2, b); editor.apply(); } }); return view; }
@Override public View getGroupView(int i, boolean b, View view, ViewGroup viewGroup) { if (view == null) { view = layoutInflater.inflate(R.layout.layout_notification_list_header, viewGroup, false); } BoxListData boxListData = getGroup(i); TextView tvGroupNotification = ViewHolder.get(view, R.id.TV_group_notification_user_setting); CheckBox cbGroupNotification = ViewHolder.get(view, R.id.CB_group_notification_user_setting); tvGroupNotification.setText(boxListData.boxName); cbGroupNotification.setChecked(LinkBoxController.defaultAlarm); cbGroupNotification.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { LinkBoxController.defaultAlarm = b; notifyDataSetChanged(); } }); return view; }