Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8138055
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T11:22:35+00:00 2026-06-06T11:22:35+00:00

I set up ABS with a simple Android project and can’t find out why

  • 0

I set up ABS with a simple Android project and can’t find out why no single part of the action bar shows up on 2.3.3 (left), but works perfectly on 4.0 (right: title, tabs and menu).

enter image description here enter image description here

What I did:

  • Created new Android Project in Eclipse
    • Added android:theme="@style/Theme.Sherlock" in <application>
    • <uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15" />
    • Changed Java compliance to 1.6 (don’t think this matters, should be the default anyway)
  • Added ABS as library project (compiled against SDK version 15 as well)
  • Did not add support library to my project (doesn’t make a difference if I do)

Note: I have to use static attachment so I cannot extend one of the Sherlock* classes.

Source code:

package de.andidog.testthesherlock;

import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.support.v4.app.FragmentTransaction;
import android.util.Log;

import com.actionbarsherlock.ActionBarSherlock;
import com.actionbarsherlock.ActionBarSherlock.OnCreateOptionsMenuListener;
import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.ActionBar.Tab;
import com.actionbarsherlock.view.Menu;
import com.actionbarsherlock.view.MenuItem;

public class TestTheSherlockActivity extends Activity implements ActionBar.TabListener, OnCreateOptionsMenuListener
{
    protected ActionBarSherlock sherlock = ActionBarSherlock.wrap(this);

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

        sherlock.setUiOptions(ActivityInfo.UIOPTION_SPLIT_ACTION_BAR_WHEN_NARROW);

        showTabsNav();

        // TODO: check order of these statements
        sherlock.setContentView(R.layout.main);

        setContentView(R.layout.main);
    }

    private void showTabsNav()
    {
        final ActionBar ab = sherlock.getActionBar();

        ab.setDisplayUseLogoEnabled(true);
        for(int i = 0; i < 5; ++i)
            ab.addTab(ab.newTab().setIcon(R.drawable.ic_launcher).setTabListener(this));

        ab.setDisplayShowHomeEnabled(true);
        ab.setDisplayShowTitleEnabled(true);
        ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    }

    @Override
    public boolean onCreateOptionsMenu(android.view.Menu menu)
    {
        return sherlock.dispatchCreateOptionsMenu(menu);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu)
    {
        menu.add("Refresh").setIcon(android.R.drawable.ic_menu_rotate).setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
        return true;
    }

    @Override
    public void onTabReselected(Tab tab, FragmentTransaction ft)
    {
        Log.d("TestTheSherlockActivity", "TAB RESELECTED");
    }

    @Override
    public void onTabSelected(Tab tab, android.support.v4.app.FragmentTransaction ft)
    {
        Log.d("TestTheSherlockActivity", "TAB CLICKED");
    }

    @Override
    public void onTabUnselected(Tab tab, FragmentTransaction ft)
    {
        Log.d("TestTheSherlockActivity", "TAB UNSELECTED");
    }
}

My AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="de.andidog.testthesherlock"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="15" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.Sherlock" >
        <activity
            android:name=".TestTheSherlockActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

How do I get this to work on 2.x?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T11:22:36+00:00Added an answer on June 6, 2026 at 11:22 am

    Remove the second setContentView call, this is overwriting the layout inflated by ABS.

    You should only be using the static attachment technique if you require extending from a non-Android base class. Otherwise it’s much easier to extend from SherlockActivity (or any of the others).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using following sql code to find out 'ALL' poi closest to the set
I'm trying to find near duplicate values in a set of fields in order
I have a dict, { foo: set([a, b]), bar: set([c, d]) } , and
I'm trying to set up a project with dependencies on ActionBarSherlock (4.0 RC1) and
I have this bit of VB6 sliced out of a project I'm working on:
I need to set alarm in google calendar via Android app. I have successfully
I am using the following code as part of a set of scrollable bars
I have viewcontrollers set up to track gestures and commit an action, in this
I want to rotate a simple GWT-Label. Is there any option? I have set
Take the following update statement. UPDATE TABLE_1 SET Units2 = ABS(Units1) ,Dollars2=ABS(Dallars1) ,Units1 =0

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.