在Android的后台堆栈中返回不同的Activity [英] Go back to different Activity in back stack in Android

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

问题描述

假设我有一个这样的活动堆栈: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,然后登陆它.

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!

推荐答案

so while 从活动 C 到 D finish(); C 活动.

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

最后在ActivityD的backPress方法调用activityEfinish();ActivityD

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

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

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