2012-05-28 19 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"); 
相關問題