public void bind(final int position) { AppContainer item = mDataset.get(position); checkbox.setChecked(item.isChecked()); title.setText(item.getFriendlyName()); description.setText(item.getPackageName()); itemView.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { AppContainer item = mDataset.get(position); if (checkbox.isChecked()) { item.setChecked(false); checkbox.setChecked(false); } else { item.setChecked(true); checkbox.setChecked(true); } mDataset.set(position, item); notifyItemChanged(position); } }); }
@Override public void setChecked(boolean checked) { super.setChecked(checked); if (mOnCheckedChangeListener != null) { mOnCheckedChangeListener.onCheckedChanged(this, checked, mFromUser); } }
private void initViews(LayoutInflater inflater) { if (slide.getTitle() != null) { title.setText(slide.getTitle()); title.setMaxLines(getLineCountForTitle()); } if (slide.getDescription() == null && slide.getOption() != null) { AppCompatCheckBox option = (AppCompatCheckBox) inflater.inflate(R.layout.introduction_fragment_option, descriptionContainer, false); option.setText(slide.getOption().getTitle()); option.setChecked(slide.getOption().isActivated()); option.setOnCheckedChangeListener( new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { slide.getOption().setActivated(isChecked); } }); option.setSupportButtonTintList( ContextCompat.getColorStateList(getContext(), android.R.color.white)); option.setMaxLines(getLineCountForDescription()); descriptionContainer.addView(option); } else if (slide.getDescription() != null) { TextView description = (TextView) inflater.inflate( R.layout.introduction_fragment_description, descriptionContainer, false); description.setText(slide.getDescription()); description.setMaxLines(getLineCountForDescription()); descriptionContainer.addView(description); } if (slide.getImageResource() != null) { image.setImageResource(slide.getImageResource()); } root.setBackgroundColor(slide.getColor()); }