I'm working with the new android toolbar.
/* Jump into, after the user clicks on a listview item */
private void toogleToolbar() {
if (isStandardToolbar)
customToolbar();
else
originalToolbar();
isStandardToolbar = !isStandardToolbar;
}
/* Called inside onCreate and if nothing was clicked */
private void originalToolbar() {
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
}
/* Called after an click event */
private void customToolbar() {
LayoutInflater inflater = this.getLayoutInflater();
Toolbar toolbar = (ToolBar) inflater.inflate(R.layout.newtoolbar, null);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayShowTitleEnabled(false);
}
It works so far, but now I want to change the toolbar view, after clicking on a list element. That's my problem, because the last code snippet doesn't produce an exception or other issues, so it should be all ok. But I see only the "old" toolbar. I tried to set visibility to GONE or INVISIBLE to the old one, but it doesn't have any effect.
In my activity_main.xml, I include R.id.toolbar, but I think, the second code must overwrite the old one!?
EDIT: AFAIK, the new toolbar should replace the old actionBar. Toolbar is used to place navigation or other, specific content. I my case, I want to create a small action menu, where the user can edit or delete a list item.