I've created a toggle button in my cardView and when the toggle button is pressed it should copy the cardItem to another fragment. I've done this for toggleButton:
holder.favButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){
@Override
public void onCheckedChanged(CompoundButton favButton, boolean isChecked){
if (isChecked)
favButton.setBackgroundDrawable(ContextCompat.getDrawable(favButton.getContext(),R.mipmap.ic_launcher));
Intent intent = new Intent(context,FavouriteFragment.class);
Bundle bundle = new Bundle();
bundle.putSerializable("DATA", (Serializable) cardItems);
intent.putExtras(bundle);
context.startActivity(intent);
}
});
and this is where i want to retrieve the values that I've put.
private void initializeCardItemList(){
CardItemModel cardItemModel;
String[] cardTitles = getResources().getStringArray(R.array.fav_cards);
String[] cardContents = getResources().getStringArray(R.array.fav_cards_content);
final int length = cardTitles.length;
for(int i=0;i<length;i++){
cardItemModel = new CardItemModel(cardTitles[i],cardContents[i]);
cardItems.add(cardItemModel);
}
}
With what I should replace this to initialize the cardItems? (* only showing cards in which toogle button is pressed)