I have this method that checks the fragment to inflate in my view:
private void startFragment(int code) {
switch (code) {
case 1:
fragmentTransaction.replace(R.id.fragment, MesAnterior.newInstance(0));
break;
case 2:
fragmentTransaction.replace(R.id.fragment, MesAtual.newInstance(1));
break;
case 3:
fragmentTransaction.replace(R.id.fragment, MesProximo.newInstance(2));
break;
}
fragmentTransaction.addToBackStack(null);
fragmentTransaction.commit();
}
I have a fragment (xml) that would get the fragment.
In the first click on the button it goes without problems, but in the second it gives the error commit already called