Indywidualny ekran jest wyświetlany zamiast tabhosta w android eclipse
Jestem self_learner do Androida.
Mam dwa ekrany. Pierwszy ekran zawiera jeden edittext i przycisk, edittext ma uzyskać dane od użytkownika i przycisku, aby wywołać aktywność tabhost na drugim ekranie.
W czasie wykonywania, po otrzymaniu danych od użytkownika, powinien on pokazywać odpowiednie wartości(zgodnie z danymi wprowadzonymi przez użytkownika) do dowolnej karty tabhost, która znajduje się na drugim ekranie.
Ale tutaj mój problem polega na pokazaniu odpowiedzi na osobnym ekranie, a nie na formacie tabhost.
UWAGA: W poniższym kodzie myślę, że tylko problem polega na użyciu współdzielonej preferencji do przechowywania i wyświetlania danych na tabhost.please, czy ktoś może mi pomóc?
Znajdź kod poniżej
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,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();
}
}
});
}
}
Tab_1.java
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);
}
}
Dzięki za twój cenny czas !!