0

Here's my layout:

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
          xmlns:tools="http://schemas.android.com/tools"
          android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:id="@+id/drawer_layout"
          tools:ignore="MergeRootFrame">
<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <include layout="@layout/toolbar"/>

    <android.support.v4.view.ViewPager
        android:layout_height="match_parent"
        android:layout_width="match_parent"
        android:id="@+id/pager">
        <android.support.v4.view.PagerTabStrip
            android:id="@+id/pager_title_strip"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_gravity="bottom"
            android:background="@color/colorPrimary"
            android:textColor="@color/colorSecondary"
            android:paddingTop="4dp"
            android:paddingBottom="4dp" />
    </android.support.v4.view.ViewPager>
</LinearLayout>

<ListView android:id="@+id/left_drawer"
          android:layout_width="320dp"
          android:layout_height="match_parent"
          android:layout_gravity="start"
          android:choiceMode="singleChoice"
          android:divider="@android:color/transparent"
          android:dividerHeight="0dp"
          android:background="#111"/>

Relevent code snippet:

mToolbar = (Toolbar) findViewById(R.id.toolbar);
if(mToolbar != null) {
    setSupportActionBar(mToolbar);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    mToolbar.setTitle("Some title");
}

The title never gets displayed. I don't get any errors, and I can make calls on mToolbar as if it were working. I also see it at the top of my app, so it's there, it's not being covered by anything else, but the text isn't updating, I can't set any icons, and nothing I do to it seems to work at all.

I have no idea what to do, the tutorials dealing with Toolbar make it seem really easy, but it's just not working.

Edit: Here's toolbar.xml

<android.support.v7.widget.Toolbar
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="120dp"
android:theme="@style/Base.Widget.AppCompat.Toolbar"
android:background="?attr/colorPrimary"/>
MrEngineer13
  • 38,642
  • 13
  • 74
  • 93
jmickela
  • 663
  • 1
  • 8
  • 17

1 Answers1

0

It turns out that I was calling setContentView from both my base activity and my main activity, and it seems that once it's called a second time, the views created from the first call are orphaned and no longer functional.

I hadn't needed to mess with my layout in my base activity before following the Toolbar tutorials, so that's why I was suddenly calling setContentView twice.

jmickela
  • 663
  • 1
  • 8
  • 17