1
我想在单击按钮时在另一个活动中显示计算的详细信息。如何实现这一点。我的第一个活动Java代码是Android意向问题
public void onClick(View v)
{
if(v.getId()==R.id.Button07)
{
String a,b;
Integer vis;
a = txtbox3.getText().toString();
b = textview1.getText().toString();
vis = (Integer.parseInt(a)*Integer.parseInt(b))/100;
tv.setText(vis.toString());
// tv is a textview where result be shown
Bundle bu=new Bundle();
bu.putString("answer",tv.toString());
Intent intent=new Intent(AdvancedCalculator.this,calculatedData.class);
intent.putExtras(bu);
startActivity(intent);
}
单击提交按钮时,应显示一个新的活动,结果将显示在已定义的布局中。
我的第二个活动类是
Bundle b=getIntent().getExtras();
String answer=b.getString("answer");
当我试图运行应用程序的应用程序崩溃。
任何帮助将不胜感激谢谢
添加日志.......... – 2011-04-30 04:45:48
不知道这是否是您的问题,但您可以通过执行intent.putExtra(key,stringValue)将额外的字符串直接放在Intent上 – dmon 2011-04-30 04:50:17