2012-05-28 24 views
0

我是Android开发中的新手,因此试着解释复杂的步骤。在另一个活动中显示结果

我想知道以下过程写什么代码: -

活性1通过的EditText需要数量的输入,然后对其执行一些动作,可以说,它与2相乘,然后发送这个新号码到另一个活动活动2它在哪里显示。

主要我想知道如何在活动中显示新号码。

Thnx提前。

+2

转到通过意图Android中添加此。你真的必须谷歌或搜索这个问题之前发布在这里。 –

+1

尝试首先在'Google'或'Stackoverflow'中进行搜索。在没有得到任何解决方案的情况下询问问题后。 – Praveenkumar

+0

See this .. http://stackoverflow.com/questions/10069609/pass-data-from-one-activity-to-another-but-go-to-the-other-activity-later – Ronnie

回答

4

你需要从一个活动数据传递到另一个活动..

Main.java

Intent it=new Intent(Main.this,Expense.class); 
it.putExtra("a", food); 
startActivity(it); 

Second.java

Bundle b=getIntent().getExtras(); 
if(b!=null) 
{ 
    String fud=b.getString("a"); 
} 
textview.setText(fud); 
+0

thnx!这就是我正在寻找的。 – Mohit

1

参见本实施例中

添加此活性1

Intent myIntent = new Intent(Activity1.this, Activity2.class); 
myIntent.putExtra("UserId",UserId); 
myIntent.putExtra("UserName",UserName); 
startActivity(myIntent); 

在活动2

Intent intent = getIntent(); 
UserId=intent.getStringExtra("UserId"); 
UserName=intent.getStringExtra("UserName"); 
相关问题