I have only one activity
and multiple fragments
in my application.
Two main fragment A(left) and B(right).
If you press back image you have to create method first like this
private void Backpresses() {
getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.contant_main, new Home()).commit();
}
then you have to call like this when you press back image..
back.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Backpresses();
}
});
It work fine for me.