0

I been using the design library and I came across a problem.

 final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
 setSupportActionBar(toolbar);
 getSupportActionBar().setDisplayHomeAsUpEnabled(true);

I initialized the Toolbar to have to back button, however it only shows in Genymotion Nexus 6. On my LG G2 Lolipop, the back button does not show. Is there a workaround for this bug? Thanks.

safaiyeh
  • 1,655
  • 3
  • 16
  • 35

2 Answers2

1

Rather, you should set the up icon on the toolbar.

Use:

toolbar.setNavigationIcon(getResources().getDrawable(R.drawable.your_icon));

You can also set the navigation icon in the xml layout of your toolbar by using the android:navigationIcon tag.

Pratyush Yadav
  • 271
  • 1
  • 13
0

I have changed a version in build.gradle from

compile 'com.android.support:design:22.2.0'

to

compile 'com.android.support:design:24.2.1'

and added this to class:

    Toolbar toolbar = (Toolbar) findViewById(R.id.mainToolbar);
    setSupportActionBar(toolbar);
    getSupportActionBar().setDisplayShowTitleEnabled(true);

Now back button is working!

Petr Tykal
  • 21
  • 1
  • 4