I have an application with a couple of fragments. I would like a variable that I can edit from each fragment. I mean my main activity shows the first fragment at start. This first fragment has the following code:
button_1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FragmentManager fragmentManager = getFragmentManager ();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction ();
fragmentTransaction.setCustomAnimations(R.anim.enter_from_right, R.anim.exit_to_left).replace(R.id.content_frame, new Fragment_2());
fragmentTransaction.commit ();
}});
So this button opens the second fragment, but before that I would like to add 1 to that integer on button click. Then the second fragment has a similar button that should do the same. How can I do that?