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

The Archive Base Latest Questions

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

I have four activities namely, Demo_tabActivity.java [main activity] Tabhost.java The below two activities are

  • 0

I have four activities namely,

  • Demo_tabActivity.java [main activity]

  • Tabhost.java

The below two activities are tabs of the above tabhost.java

  • Tab_1.java

  • Tab_2.java

The first activity(Demo_tabActivity.java) contains an edittext & button.The second(Tabhost.java) activity contains a Tabhost widget.The third & fourth activities contains textviews respectively.

The first activity is going to consume a web service by getting the input from the user and returns some data on first tab(third activity) of a tabhost(second activity).

Well consuming of webservice is working well and returns the value perfectly,

but, the problem is, its showing the result on the separate page instead of showing on the tabhost.

Demo_tabActivity.java

 public class Demo_tabActivity extends Activity 
 {

private static String NAMESPACE = "http://tempuri.org/";
   private static String METHOD_NAME = "FahrenheitToCelsius";
   private static String SOAP_ACTION = "http://tempuri.org/FahrenheitToCelsius";
   private static String URL = "http://www.w3schools.com/webservices/tempconvert.asmx?WSDL";

   Button btnFar;
   EditText txtFar;

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

       btnFar = (Button)findViewById(R.id.button1);

       txtFar = (EditText)findViewById(R.id.editText_in);

       btnFar.setOnClickListener(new View.OnClickListener()
       {
       public void onClick(View v)
       {
           String b;

         //Initialize soap request + add parameters
         SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);       

         //Use this to add parameters
         request.addProperty("Fahrenheit",txtFar.getText().toString());

         //Declare the version of the SOAP request
         SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);

         envelope.setOutputSoapObject(request);
         envelope.dotNet = true;

         try 
         {
             HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);

             //this is the actual part that will call the webservice
             androidHttpTransport.call(SOAP_ACTION, envelope);

             // Get the SoapResult from the envelope body.

             SoapPrimitive result = (SoapPrimitive)envelope.getResponse();

             if(result != null)
             {
              //Get the first property and change the label text

                b = result.toString();
                Intent itnt = new Intent(v.getContext(), Tab_1.class);
                itnt.putExtra("gotonextpage", b.toString());
                startActivity(itnt);
             }
             else
             {
           Toast.makeText(getApplicationContext(), "NoResponse",Toast.LENGTH_SHORT).show();
             }
         }
        catch (Exception e)
        {
           e.printStackTrace();
           }
         }
       });
       }

NOTE: I’ve only doubt on if condition in the above code


Tab_1.java

public class Tab_1 extends Activity 
{
TextView tv;
String result;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);

Bundle extras = getIntent().getExtras();
if(extras != null)
{   result = extras.getString("gotonextpage");  }
tv = (TextView)findViewById(R.id.textView_main2);
tv.setText(result);
}}

Tabhost.java

 public class Tabhost extends TabActivity {

@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.main1);


    TabHost tabHost = getTabHost();
    TabHost.TabSpec spec;
    Intent intent;

    intent = new Intent().setClass(this, Tabhost.class);
    spec = tabHost.newTabSpec("first").setIndicator("First").setContent(intent);
    tabHost.addTab(spec);

    intent = new Intent().setClass(this, Tab_2.class);
    spec = tabHost.newTabSpec("second").setIndicator("Second").setContent(intent);
    tabHost.addTab(spec);

    tabHost.setCurrentTab(0);
    }
}
  • 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-06T05:22:12+00:00Added an answer on June 6, 2026 at 5:22 am

    Your problem is because you aren’t including Tab_1 in your tabhost (and you are self referencing TabHost… not sure how that’s not causing a crash…).

    I believe this line:

    intent = new Intent().setClass(this, Tabhost.class); 
    

    needs to be changed to this (or add another TabSpec with it):

    intent = new Intent().setClass(this, Tab_1.class); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have four activities namely, Demo_tabActivity.java [main activity] Tabhost.java The below two activities are
I have a Weather app with four Activities. The main/launcher activity is 'invisible' using...
I have Main Activity. That has 4 tabs ( TabHost ). I have overridden
I am a beginner in android. I have four stages (four activities). In activity
I have four activities, A, B, C and D. app starts with activity A,
I need some help :) I have a tab activity with four sub activities.
I have four activities A,B,C,D. I am passing an text from activity A to
I have an Android application which has four tabs (I use a main TabActivity
I have four tabs created by a piece of coding and I would like
I have four or five difference java installations on my Linux computer. I have

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.