简体   繁体   English

单击按钮从我的第二个活动返回到第一个活动后,整个数据都消失了

[英]after returning back from my second Activity to first Activity on clicking button the whole data is gone

I have two activties: activity_main, activity_display我有两个活动:activity_main,activity_display

in the main_activity user enters his/her name and presses the toggle button to display.在 main_activity 用户输入他/她的名字并按下切换按钮来显示。 that takes the user to display_activity page where the result is displayed.将用户带到显示结果的 display_activity 页面。 if the user finds that he/she has entered the wrong info they can go back and edit.如果用户发现他/她输入了错误的信息,他们可以 go 返回并编辑。

here is where the problem starts after pressing the toggle button - display it goes to display_activity and displays but when I press "back" button I'm restarting the whole (first) main_activity again... no values are present... even the toggle button that needs to be set to "reset" is again showing "display".这是按下切换按钮后问题开始的地方 - 显示它转到 display_activity 并显示,但是当我按下“返回”按钮时,我再次重新启动整个(第一个)main_activity......没有值存在......即使是需要设置为“重置”的切换按钮再次显示“显示”。

should i use something else instead of我应该用别的东西代替

                        startActivity(intend1);

i want to resume the (first) activity main not restart everything我想恢复(第一个)活动主要不重新启动一切

Seems like your first activity uses results from second activity.似乎您的第一个活动使用了第二个活动的结果。 you can use startActivityForResult.您可以使用 startActivityForResult。 Here is a very good answer refer to it.这是一个非常好的答案,请参考它。

How to manage startActivityForResult on Android 如何在 Android 上管理 startActivityForResult

暂无
暂无

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

相关问题 如何将第一个Activity中的数据保存到第二个Activity中? - How to save the data in my ListView from the first Activity to the second Activity? 如何根据第一活动数据(单击单选按钮)从第二活动转到第三活动或第四活动? - How to go from second activity to third activity or fourth activity based on first activity data (Radio button clicked)? 重新单击 MainActivity 中的按钮以启动第二个活动后,如何在第二个活动中保留价值? - How to retain value in second activity after re-clicking the button from MainActivity to launch the second activity? 将数据从第二个活动移到第一个活动 - Move Data from Second Activity to first Activity 将主要活动中的第一个按钮链接到网站后,如何将按钮链接到第二个活动? - how do i link a button to a second activity after linking the first buttons in my main activity to websites? 单击按钮后,第二个活动确实打开 - Second Activity doesent open up after clicking the button 单击按钮后应用程序关闭,而不是返回到主要活动 - App closes after clicking a button instead of returning to main activity 显示有关第二个活动中设置的第一个活动的数据 - Displaying data on first activity that is set in the second activity 从第二个活动中按下主页返回按钮时不会在活动中返回相同的片段 - From second activity when press home back button do not came back same fragment in a activity 单击后退按钮两次以退出活动 - Clicking the back button twice to exit an activity
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM