Change icon action back with fragment

5

Good morning,

I'm having trouble changing the back icon action

asked by anonymous 03.11.2015 / 14:34

1 answer

1

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 .

    
03.11.2015 / 15:38