I have a cardView
that has a textView
and a Like button. Whenever the like button is pressed it will display that cardView
in another fragment, just like favourites.
How can I do this using shared preference or any other method? I've done this to change the color of like button but don't know how to add that cardView
to another fragment:
likeImageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
int id = (int)likeImageView.getTag();
if( id == R.drawable.ic_like){
likeImageView.setTag(R.drawable.ic_liked);
likeImageView.setImageResource(R.drawable.ic_liked);
Toast.makeText(getActivity(),titleTextView.getText()+" added to favourites",Toast.LENGTH_SHORT).show();
} else {
likeImageView.setTag(R.drawable.ic_like);
likeImageView.setImageResource(R.drawable.ic_like);
Toast.makeText(getActivity(),titleTextView.getText()+" removed from favourites",Toast.LENGTH_SHORT).show();
}
}
});