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 555727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:50:41+00:00 2026-05-13T11:50:41+00:00

Since I am new to Android, I am now thinking on what is the

  • 0

Since I am new to Android, I am now thinking on what is the correct way of doing things.

As it stands, the application I’m writing has 4 different screens:

  • Screen 1 – list of nodes (main screen)
  • Screen 2 – options menu, tableLayout with buttons
  • Screen 3 – navigation
  • Screen 4 – text details on version etc

These screens can be navigated to/from using a “header” View that is placed on top. The header then has 4 different buttons:

+--------------------+
| menu with buttons  |
+--------------------+
|                    |
|                    |
|                    |
|  C O N T E N T     |
|                    |
|                    |
|                    |
+--------------------+

main.xml is really just a LinearLayout that INCLUDES the header.xml and then the content, in that case the list of nodes in a ListView

options.xml is the same thing almost, it includes the headerxml and then a bunch of buttons…

…and so on with the two other screens.

So, when I press one of the buttons in the header/menu on top the content should be switched to that screen. My question is:

  • Should I create one Activity for each screen? I read on Google that:
    An activity presents a visual user interface for one focused endeavor the user can undertake. So that can be interpreted that I should use one Activity for each of these screens.

  • Should I not create more Activities than the startup, and then just run the setContentView(R.layout.whatever) when I want to change the “content” above?

  • 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-05-13T11:50:41+00:00Added an answer on May 13, 2026 at 11:50 am

    You should probably use a separate Activity for each screen; otherwise you need to end up keeping track of which individual View is currently being displayed, plus the state of all those not currently being displayed when the user switches to another window, or a call comes in etc.

    It’s easier to keep track of this state if you just use a separate Activity for each piece of functionality.

    If you do decide to keep everything in a single Activity however, you could look at the TabActivity class. However, there are also caveats there that prevent you from having an Activity as the tab content.

    • Android: Why shouldn't I use activities inside tabs?

    Regarding your follow-up, you unfortunately cannot attach an Intent directly to a Button like you can with a MenuItem via the XML, however you could just extend Activity to make your own common base class with some code that hooks up the listeners.

    Something like:

    public class BaseActivity extends Activity {
        protected View.OnClickListener mButtonListener;
    
        protected void setupHeaderButtons() {
            findViewById(R.id.header_btn_1).setOnClickListener(mButtonListener);
            // ...
            findViewById(R.id.header_btn_n).setOnClickListener(mButtonListener);
        }
    }
    
    public class FirstActivity extends BaseActivity {
        @Override
        public void onCreate(Bundle b) {
            super.onCreate(b);
            setContentView(R.layout.first_activity);
    
            // This needs to be done *after* the View has been inflated
            setupHeaderButtons();
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm new to android developing but right now I'm working on an application that
I am working on a small MFC application..since am new to MFC I am
I am new to Oracle. Since we have rewritten an earlier application , we
The UI in Android Honeycomb is very different. I'm looking for things that have
I have an application that has been running fine since its launch over a
I'm using osmdroid on my new Android project (since I want to be able
I've developed Android for a while now, using WIN7 64bit and Eclipse. Since I've
I'll have to get a new cell pretty soon since my current phone has
I have an Android application that works with sms messages. When new sms message
I'm trying to build a valid junit testing suite on android. Since i'm new

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.