Sunday, September 27, 2015

Hide ActionBar Title

So I'm new to Android development, and was playing around with a sample application template. Using the ActionBar to place tabbed navigation up top, but I want to hide the title. Using the FEATURE_NO_TITLE method crashes (and yes it was before setContentView). Tried many different android:theme settings in the manifest. Nothing worked.

Then I stumbled upon this, which did work:
protected void onCreate(Bundle savedInstanceState) {

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(0); // <----- THIS IS THE PART THAT WORKED.

    // etc...
Also worth noting that in my case I'm not displaying an options menu, via:
public boolean onCreateOptionsMenu(Menu menu) {
    return false;