Note that there are some explanatory texts on larger screens.

plurals
  1. POIndividual screen is showing instead of a tabhost in android eclipse
    primarykey
    data
    text
    <p>i am self_learner to android.</p> <p>I have two screens.The first screen contains one edittext and a button,the edittext is to get the input from the user and button is to call the tabhost's activity which is on the second screen.</p> <p>During run time, after getting input from the user,it should show the appropriate values <strong>(as per the user's input)</strong> to any one of the tab of a tabhost which is on the second screen.</p> <p>But here my problem is,its showing the answer on the separate screen,not on the tabhost format.</p> <p><strong>NOTE:</strong> In the below code i guess only the problem is on using the shared preference to store and display the data to tabhost.please can any one help me?</p> <p>Please find code below</p> <p><strong>Demo_tabActivity.java</strong></p> <pre><code> 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,txtshow; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); txtFar = (EditText)findViewById(R.id.editText_in); btnFar = (Button)findViewById(R.id.button1); 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(); SharedPreferences sharedPreferences; sharedPreferences=PreferenceManager.getDefaultSharedPreferences(Demo_tabActivity.this); Editor editor = sharedPreferences.edit(); editor.putString("your", "b"); editor.commit(); if(result != null) { b=result.toString(); Intent i = new Intent(getApplicationContext(),Tab_1.class); i.putExtra("goto", b.toString()); startActivity(i); } else { Toast.makeText(getApplicationContext(), "oops!..empty",Toast.LENGTH_SHORT).show(); } } catch (Exception e) { e.printStackTrace(); } } }); } } </code></pre> <p><strong>Tab_1.java</strong></p> <pre><code> public class Tab_1 extends Activity { EditText tv; String result; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.tab1); SharedPreferences sharedPreferences; sharedPreferences = PreferenceManager.getDefaultSharedPreferences(Tab_1.this); String answer= sharedPreferences.getString("your",""); Bundle extras = getIntent().getExtras(); if(extras !=null) { result = extras.getString("goto"); } tv=(EditText)findViewById(R.id.editText_output); tv.setText(result); } } </code></pre> <p>Thanks for your precious time!!</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload