Search code examples
android-fragmentsactionbarsherlockandroid-actionbarandroid-fragmentactivityandroid-support-library

ActionBarSherlock doesn't show title


public class Intro extends SherlockFragmentActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.generic);

        final ActionBar bar = getSupportActionBar();
        bar.setTitle("test title");
        bar.setTitle("test subtitle");

The last two lines have no effect: the title and the subtitle are simply not set. The action bar only contains the logo. Strangely, I haven't found any similar questions, so I must be doing something very wrong.

This is the layout file generic.xml:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >
</RelativeLayout>

Any ideas?


Solution

  • After an hour of frustration I noticed that for some reason I had the following call a few lines down the road:

    bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
    

    Never code after midnight...