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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:12:32+00:00 2026-05-23T15:12:32+00:00

I want to create application with two Tabs, like follow: MainClass: private TabHost tabHost;

  • 0

I want to create application with two Tabs, like follow:

MainClass:

private TabHost tabHost;

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

    tabHost = (TabHost)findViewById(android.R.id.tabhost);

    TabSpec firstTabSpec = tabHost.newTabSpec("tid1");
    TabSpec secondTabSpec = tabHost.newTabSpec("tid2");

    firstTabSpec.setIndicator("First Tab Name").setContent(new Intent(this,MainTab.class));
    secondTabSpec.setIndicator("Second Tab Name").setContent(new Intent(this,ResultTab.class));

    tabHost.addTab(firstTabSpec);
    tabHost.addTab(secondTabSpec);
}

public TabHost getTabHost() {
    return tabHost;
}

FirstTab:

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.maintab);
    }

SecondTab:

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

On First tab i have some buttons, with who i calculate some mathematic operations. A want to display result on SecondTab when calculating is finished.

First problem:
I do not know, how can I send data (String) from FirstTab to SecondTab.
I tray:

  • creating self parameter in Tab class,
  • setOnTabChangedList
  • and some similar
    but without results.

Second problem (small for now 🙂 ):
When I selected some parameters (my buttons, list, …) on FirstTab and change view to SelectTab, and return to FirstTab selected parameters are gone.

Anyone help me?

  • 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-23T15:12:33+00:00Added an answer on May 23, 2026 at 3:12 pm
    1. You can send strings with intents. For example:

      Intent intent = new Intent().setClass(this, Secondtabclass.class);
      intent.putExtra(“mykey”, “string to send”);

      startActivity(intent);

    And then on the recieving activity you do:

    String recievedString = this.getIntent().getStringExtra("mykey");
    
    1. You could save the state of your list and whatever you like if you override OnResume and OnPause methods. On pause gets called every time your activity loses focus, and on resume gets called every time your activity resumes focus. Like this:

      @Override
      protected void onResume() {
      super.onResume();

          //Do stuff
      }
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i want to create an application in android ,for two country like U.S. or
I want to create a Java application bundle for Mac without using Mac. According
I want to create my Rails application with MySQL, because I like it so
I want to create a C# application in which copy some files in two
I want to create two new custom buttons to use in my android application.
I want to create an application which will have a client and server components.
I want to create a c# application with multiple windows that are all transparent
Say I want to create vb.net application in Visual studio 2005. What is the
I want to create a volume slider for my application. I don't mind whether
I want to create an ini file to store some settings for my application.

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.