no actionbar

When copying projects from an Android sample project I’ve found that when the app runs there is no action bar visible. Solved this by the following.

Into the top of the activity put

android.support.v7.app.ActionBar ab;

Into onCreate put

actionBarSetup();

Create method

    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    private void actionBarSetup() {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            ab = getSupportActionBar();
    }

Change Activity to AppCompatActivity.

This entry was posted in Android. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *