eclipse没有android选项卡,在android eclipse中显示单个屏幕而不是tabhost

我是android的自我导师.

我有两个屏幕.第一个屏幕包含一个edittext和一个按钮,edittext用于获取用户的输入,按钮用于调用第二个屏幕上的tabhost活动.

在运行期间,在从用户获得输入之后,它应该向第二个屏幕上的tabhost的任何一个选项卡显示适当的值(根据用户的输入).

但在这里我的问题是,它在单独的屏幕上显示答案,而不是tabhost格式.

注意:在下面的代码中我想只有问题是使用共享首选项来存储和显示数据到tabhost.please可以帮助我吗?

请在下面找到代码

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);

}

}

谢谢你宝贵的时间!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值