This is my scenario, I have Activity
with Navigation Drawer
implemented, and in that Activity
contains a container where Fragments
is called.
My problem is this: I want the Navigation Drawer
burger icon to be replaced with a Back Arrow when opening a certain Fragment
and works just like a back button, and when I close this Fragment
, the icon Navigation Drawer
burger come back.
I used getSupportActionBar().setDisplayHomeAsUpEnabled(true)
when calling Fragment
on Activity
, Back Arrow appeared but instead of returning, it opens navigation drawer
.
I also gave Override
in OnOptionItemSelected
of Activity
, but to no avail.
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if(item.getItemId() == android.R.id.home){
onBackPressed();
}
return super.onOptionsItemSelected(item);
}
Can anyone give me a light on how to implement this back button without having to call a Activity
instead of Fragment
?