繁体   English   中英

是否可以在不使用 Intent 的情况下将 Edittext 值从一个活动传递到另一个活动

[英]Is it Possible to Pass Edittext Value from one activity to another activity without using Intent

Intent intent = new Intent(this, Page.class); 
intent.putExtra("arg", getText);
startActivity(intent);


//second activity:

String passedArg = getIntent().getExtras().getString("arg");
enteredValue.setText(passedArg);

在不使用意图的情况下从一项活动获得另一项活动的价值....?? 我想在其他活动edittext中显示edittext传递的数据但不使用意图......? 请帮助我是否可能....??

有很多方法:事件总线、SharedPreferences、通过全局对象(应用程序类)、数据库、简单文件。 但为什么?

首先尝试直接和可读的风格。

如果您无法将要保存在 Intent 中的值捆绑在一起,则可以使用SharedPreferences 更多信息在这里

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM