gpt4 book ai didi

java - 如何在 Android 中将数据从一个 Activity/Screen 检索到另一个 Activity/Screen?

转载 作者:行者123 更新时间:2023-12-01 15:29:43 26 4
gpt4 key购买 nike

我在一个 Activity 中创建了一个表单(这个表单有一些 TextView 和编辑文本字段)。
填写表格后,说我接受并单击提交按钮,我应该会看到一个新屏幕,其中包含我在表格中填写的所有字段并要求我确认。单击确认按钮后,它应该最终出现在另一个 Activity/屏幕中。有谁能够帮助我?

先感谢您)
斯韦莎

最佳答案

您可以使用以下意图传递原始数据,如字符串等

String fName_temp   = "aaa";
String lName_temp = "ccc";
String age_temp = "12";
String address_temp = "test Address";

Intent i = new Intent(this, ToClass.class);
i.putExtra("fname", fName_temp);
i.putExtra("lname", lName_temp);
i.putExtra("age", age_temp);
i.putExtra("address", address_temp);
startActivity(i);

然后在第二个 Activity 中,您可以使用,
Intent i = getIntent();
String fName = i.getString("fname");

等等

关于java - 如何在 Android 中将数据从一个 Activity/Screen 检索到另一个 Activity/Screen?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9697305/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com