3

In my Android Project, whenever I go from First Activity to Second, I get an left arrow button followed by the some text in the action bar. That left arrow only comes when I set my First Activity as the hierarchical parent of the Second Activity.

I want to remove that back button and replace it with an icon. I have read other posts for the same question, and so I have already tried the following code in my onCreate() method.

getActionBar().setDisplayHomeAsUpEnabled(false);

But after reaching to the second activity, the app gets crashed.

Please help me out.

ks_mani
  • 169
  • 1
  • 5
  • 18

2 Answers2

7

Use getSupportActionBar() bar:

getSupportActionBar().setDisplayHomeAsUpEnabled(false);
getSupportActionBar().setHomeButtonEnabled(false);
Juanjo Vega
  • 1,410
  • 1
  • 12
  • 20
0
getSupportActionBar().setHomeAsUpIndicator(R.drawable.ic_yourindicator);
sakir
  • 3,391
  • 8
  • 34
  • 50