返回Android中堆栈中的其他活动 [英] Go back to different Activity in back stack in Android

查看:67
本文介绍了返回Android中堆栈中的其他活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我有一个活动堆栈,例如: A-> B-> C-> D

Say I have an activity stack as such: A -> B -> C -> D

我想创建一个新的活动"E",并以这样的堆栈结束: A-> B-> E

I would like to create a new activity "E", and end up with a stack like this: A -> B -> E

基本上,点击活动D中的后退"按钮后,我需要将活动C换成活动E,然后降落在活动E上.

Basically, upon hitting the back button in activity D, I need to swap out activity C for activity E, and land on it.

这可能吗?还是我应该以某种方式构造导航?谢谢!

Is this possible? Or should I be structuring the navigation differently somehow? Thanks!

推荐答案

因此,从活动 C转到D finish(); C 活动.

so while going from activity C to D finish(); C activity.

最后在活动 D 的backPress方法中调用活动 E finish();活动 D

At last at backPress method of Activity D call activity E and finish(); Activity D

这篇关于返回Android中堆栈中的其他活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆