Good morning,
I'm having trouble changing the back icon action
Good morning,
I'm having trouble changing the back icon action
To override the Up Navigation action in the fragment, you need to do some things:
First:
In%% of fragment, declare this method:
setHasOptionsMenu(true); // Informa ao Android que este fragment contém menu próprio
After this, in this same fragment, of onCreateView
in method @Override
:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == android.R.id.home) { // Captura toques no Up Navigation
// Faça a ação que você quiser
}
When you do this, you can make Up Navigation specific to the fragment in question.
EDIT:
I took a look at the code you added, try adding this method to onOptionsItemSelected
of your onCreate
:
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Do this after setting MainActivity
.