I ask myself the following head breaks:
I would like to create a Favorites button that has the two following states:
1st state: "Add to Favorites"
2nd state (on OnClick event): "Remove from favorites"
But I'd also be able to return to the 2nd state: "Add to Favorites" by a 2nd OnClick event ect..
Does anyone have a solution for it with a simple OnClickListener it seems impossible.
i tried something basic like this:
- Code: Select all
private Boolean check;
favoris_button = (Button) findViewById(R.id.promotion_favoris);
if (check == true)
favoris_button.setText("Supprimer des favoris");
favoris_button.setText("Ajouter aux favoris");
public void onClick(View v)
check = true;
But the problem is that i want to immediatly change the button view on my current activity.. it could only run if OnCreate() method of the activity was recalled..