我是Android开发中的新手,因此试着解释复杂的步骤。在另一个活动中显示结果
我想知道以下过程写什么代码: -
活性1通过的EditText需要数量的输入,然后对其执行一些动作,可以说,它与2相乘,然后发送这个新号码到另一个活动活动2它在哪里显示。
主要我想知道如何在活动中显示新号码。
Thnx提前。
我是Android开发中的新手,因此试着解释复杂的步骤。在另一个活动中显示结果
我想知道以下过程写什么代码: -
活性1通过的EditText需要数量的输入,然后对其执行一些动作,可以说,它与2相乘,然后发送这个新号码到另一个活动活动2它在哪里显示。
主要我想知道如何在活动中显示新号码。
Thnx提前。
你需要从一个活动数据传递到另一个活动..
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);
thnx!这就是我正在寻找的。 – Mohit
Intents in Android是你在找什么
以下问题的答案显示了如何在活动之间传递数据。在此之前仔细阅读有关意图。
How do I pass data between Activities in Android application?
喜欢别人的问题/答案不是回答方式。 – Lucifer
参见本实施例中
添加此活性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");
转到通过意图Android中添加此。你真的必须谷歌或搜索这个问题之前发布在这里。 –
尝试首先在'Google'或'Stackoverflow'中进行搜索。在没有得到任何解决方案的情况下询问问题后。 – Praveenkumar
See this .. http://stackoverflow.com/questions/10069609/pass-data-from-one-activity-to-another-but-go-to-the-other-activity-later – Ronnie