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

  • Home
  • SEARCH
  • 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 8833967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:54:35+00:00 2026-06-14T08:54:35+00:00

this is my first app for android, I’ve been an iPhone dev for 3

  • 0

this is my first app for android, I’ve been an iPhone dev for 3 years, it’s been a change of mindset, and I still find some things odd. First I don’t know if this iPhone background might be causing some troubles, but here’s what I’m trying to do:

I want to implement an ActionBar with two options working like a TabBar from iOS:

ActionBar

What I want is that when the user selects an action, some Activity will be presented to the user.

Here’s what I’m doing so far (which isn’t that much):

  • I’m Using ActionBarSherlock, I have 3 activities: myApp, First and Second

myapp.java only creates the ActionBar elements and loads the activity_first:

package com.example.myApp;

import com.actionbarsherlock.ActionBarSherlock;
import com.actionbarsherlock.view.MenuItem;

import android.os.Bundle;

import com.actionbarsherlock.ActionBarSherlock.OnCreateOptionsMenuListener;
import com.actionbarsherlock.app.SherlockActivity;
import com.actionbarsherlock.view.Menu;

public class myApp extends SherlockActivity implements OnCreateOptionsMenuListener {
    ActionBarSherlock mSherlock = ActionBarSherlock.wrap(this);

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

        setTitle("myApp");
        mSherlock.setContentView(R.layout.activity_first);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        menu.add("First")
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

        menu.add("Second")
            .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM | MenuItem.SHOW_AS_ACTION_WITH_TEXT);

        return true;
    }
}

The activities have nothing so far, apart from the generated stub:

import android.app.Activity;
import android.os.Bundle;

public class First extends Activity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_first);


    }
}

So I have 1 Question and 1 problem:

  1. Question: Is this the correct use of an ActivityBar? I mean, should it be used to switch activities?
  2. Problem: As you can see in the OnCreate method of myApp class, I’m loading the activity_first, It does load the activity, however it loads the ActionBar Twice, like so:

enter image description here

I don’t get why is it being loaded twice. If I remove the line: mSherlock.setContentView(R.layout.activity_first); it loads the Bar once, obviously I need to load the activity…

Also I’ve assigned the NoActionBar theme to the activity_first in the graphical editor of the XML (activity_first.xml), but it doesn’t work. What Can I do to load it just once.

Thank you for your valuable time.

  • 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-14T08:54:36+00:00Added an answer on June 14, 2026 at 8:54 am

    Is this the correct use of an ActivityBar? I mean, should it be used to switch activities?

    You can think of “First” and “Second” as being the equivalent of toolbar buttons in a desktop app. You are welcome to have those action bar items start up activities if you wish.

    As you can see in the OnCreate method of myApp class, I’m loading the activity_first, It does load the activity, however it loads the ActionBar Twice, like so:

    Delete this line:

    ActionBarSherlock mSherlock = ActionBarSherlock.wrap(this);
    

    and change mSherlock.setContentView(R.layout.activity_first); to just setContentView(R.layout.activity_first);. I believe that will clear up your problems.

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

Sidebar

Related Questions

Bear with me, as this is my first Android app. :) Essentially, I would
Up front: This is my first attempt at an Android app. I'm in that
How to create in-app step by step instructions? Like this ( first boot android
This is my first android app and I'm a little disapponted because I'm not
This is my first Android app. I need to email what I have so
I am trying to create my first Android app and need some help. Basically
This is my first android app. I am posting the code I am using
To begin with, this is the first Android app I'm writing, and I have
This is my first Android app and I've encountered an exception when trying to
Let me start by explaining this is my first Android app. So I don't

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.