简体   繁体   English

使用后退按钮移至父级活动而不完成子级活动

[英]Move to parent activity without finishing child activity using back button

Is it possible to go one activity back without finishing the one you're leaving? 是否可以在不完成要离开的活动的情况下返回一项活动? In my android app, I have a drawer activity, which with a drawer item click opens a new activity. 在我的android应用中,我有一个抽屉活动,通过单击抽屉项目可以打开一个新活动。 However, when I try to move back to the drawer activity using the back button, the newly opened activity is destroyed. 但是,当我尝试使用“后退”按钮移回到抽屉活动时,新打开的活动将被破坏。 Is it possible to move that activity back so it runs in background? 是否可以将该活动移回后台运行?

Move from drawer activity to next activity by setting the flag to clear the stack and now stack only has one activity which need to run in background now open drawer activity. 通过设置标志以清除堆栈,从抽屉活动移至下一个活动,现在堆栈只有一个活动需要在后台运行,现在打开抽屉活动。

ie

A => drawer activity A =>抽屉活动

B => activity which need to run in background B =>需要在后台运行的活动

Step-1 第1步

open A 打开A

now stack has only A 现在堆栈只有一个


Step-2 第2步

move from A -> B by clearing the flag 通过清除标志从A-> B移动

now stack has only B 现在堆栈只有B


Step-3 第三步

move from B -> A 从B-> A移

now stack has only B and A. A is on top of stack and B is still in stack 现在堆栈只有B和A。A在堆栈顶部,B仍在堆栈中

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

相关问题 如何在不完成/停止孩子活动的情况下从孩子活动中完成父母活动? - How to finish parent activity from child activity without finishing/stopping child activity? 如何通过后退操作栏按钮 go 回到活动而不重新创建父活动 - How to go back to a activity through the back action bar button without recreating the Parent activity 从内部片段完成ActionBar后退按钮活动 - ActionBar back button finishing activity from inner Fragment 反压片段整理活动 - back press on fragment finishing activity 如何在没有完成活动的情况下从最近的列表返回上一个应用 - How to back to last app from recent list without finishing activity 与父活动在不同的过程中完成子活动。 finishActivity()无法正常工作 - Finishing a child Activity, in a different process, from parent Activity. finishActivity() not working 如何在没有按钮的情况下导航回主要活动 - How to navigate back to main activity without a button 如何从没有按钮的活动中返回 - How to back from the activity without button 完成活动后,我回到了第一次活动 - Finishing an activity brings me back to my first activity 如何在不编写任何代码的情况下使用从父活动到每个子活动的单一视图? - How to use a single view from the parent activity to each child activity without writing any code in child activity?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM