I'm currently updating a Fragment
oriented app (I have one Activity
with a FrameLayout
container as host for all my Fragment
s) to Material Design. And I would like to animate the burger icon to the back arrow when replacing a Fragment
.
Basically, if this wasn't clear enough, here is what I want to achieve. I don't want to use this library (MaterialMenu), I'd like to use the official AppCompat
lib to the extend of possible.
I achieved this effect thanks to this solution, but I can't figure out how to make to ActionBarDrawerToggle
as a back button when a Fragment
is replaced.
So my questions is : should the back arrow icon still be the ActionBarDrawerToggle
once the Fragement
has been replaced? In which case how do I override it so it acts like onBackPressed()
instead of openning the drawer ? I already tried this but it doesn't work :
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
switch (item.getItemId())
{
case android.R.id.home:
getActivity().onBackPressed();
return true;
}
return false;
}
Thanks in advance.