如何标记活动 [英] How to tag Activity

查看:99
本文介绍了如何标记活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这个code跳回活动栈(主要是转移到家庭活动):

I'm using this code to jump back in activity stack (mainly to move to home Activity):

Intent goTo = new Intent(this, HomeActivity.class);
goTo.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(goTo);


所以我创造新的意图,将目标,以HomeActivity这是在活动堆栈这样整个堆栈将被从上清除这个HomeActivity。
现在我需要稍微不同的用例。我有例如五项活动ABCDE(A开始乙等)堆栈。现在我需要跳转从E到C或B取决于什么样的用户选择。问题是,活动中,B,C,D,E拥有同一个类。所以我不能使用上面,因为我不知道该如何定位该活动的例子。
所以,问题是,如果有什么办法如何标签的活动或操作与堆栈。
谢谢!


So I create new Intent and set "target" to HomeActivity which is in Activity stack so whole stack will be cleared from top to this HomeActivity.
Now I need slightly different use case. I have for example five Activities A-B-C-D-E (A started B etc.) on the stack. Now I need to jump from E to C or B depending of what user choose. The problem is that Activities A, B, C, D, E have same class. So I can't use example above because I don't know how to target that Activity.
So the question is if there is any way how to "tag activity" or manipulate with stack.
Thanks!

推荐答案

最好的和最简单的解决方案(到目前为止)将利用碎片和FragmentManager。然后标记每个片段,并使用FragmentManager。仅使用活动可以是非常困难的具有几乎相同的结果。

The best and the easiest solution (so far) will be use Fragments and FragmentManager. Then tag each Fragment and use FragmentManager. Using only Activity can be very difficult to have almost the same result.

这篇关于如何标记活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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