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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:30:48+00:00 2026-06-16T04:30:48+00:00

In my main activity is there a difference between loading a view as an

  • 0

In my main activity is there a difference between loading a view as an intent or using setContentView?

public class MainActivity extends Activity {
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
  }
}

Or is this better? Not sure what the differnce is if they both load the layout file?

public class MainActivity extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         Intent i = new Intent(MainActivity.this, CalculateTip.class);
         startActivity(i);
    }
}
  • 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-16T04:30:49+00:00Added an answer on June 16, 2026 at 4:30 am

    The difference is that with the first way you are not creating a new Activity, you are simply changing the layout of the current Activity. With the second way, you are creating a new Activity.

    The practical difference will be that with the second way after you’ve started the new Activity you can press the back button and be taken back to the first. Whereas with the first way once the second layout is shown if you pressed the back button it would finish the current (only) activity which would put the user back to whatever they were doing before entering your application.

    Which is “better” is impossible to determine without knowing more about what specifically you are trying to accomplish.

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

Sidebar

Related Questions

Main Activity: private Button btnSubmit; private DataSource mDataSource; private Context mContext; @Override public void
Splash I have main activity UI startup operations that take between 5-10 seconds (that
Say I'm on my main activity and I start a new activity MainActivity >
My current application has one Activity, the main one which extends ListActivity (listview of
I am using relative layout for one of my main activity with a image
The main activity includes some variables with set values. I created a sub-activity with
Below is my main activity file. I am stuck with the bottom area (commented
I'm navigating from: Main activity to Activity 2 Activity 2 to Activity 3 Activity
I called my main activity Main, and Eclipse created Main.java and res/layout/main.xml for the
i have main activity in which i have Four menus. and i have one

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.