在Android中可以有活动的层次结构吗?

huangapple go评论83阅读模式
英文:

Can there be a hierarchy of activities in Android?

问题

我正在构建一个移动银行应用程序。第一个活动是 LoginActivity。如果用户输入正确的凭据,将打开一个新的活动 HomePageActivity。这里有一个 FrameLayout,可以在 4 个片段之间切换:HomeFragmentTransactionsFragmentTransfersFragmentReportsFragment。在 HomeFragment 中有一个按钮,当按下时,会出现一个 DialogFragmentAddDepositFragment。等等。我已经包含了一张表示"层次结构"的图片。
现在的问题是:这可以被视为一个层次结构吗?

在Android中可以有活动的层次结构吗?

英文:

So I am building a mobile banking application. The first activity is the LoginActivity. If the user enters the correct credentials, a new activity is opened, HomePageActivity. Here is a FrameLayout that can be switch between 4 fragments: HomeFragment, TransactionsFragment, TransfersFragment, ReportsFragment. In the HomeFragment is a button that when pressed, a DialogFragment appears : AddDepositFragment. And so on. I have included a picture representing the "hierarchy".
And now the question is: CAN this be considered a hierarchy?在Android中可以有活动的层次结构吗?

答案1

得分: 0

"Activities" 被组织在 "stack" 中。每个你已经打开的 "Activity" 都被放置在这个 "stack" 的顶部。

"Android" 支持修改这种行为,例如,新打开的 "Activity" 可以放在新的 "stack" 中。要了解更多可能的选项,请查看此官方文档

多窗口模式需要进一步调查。

从你的问题中,我了解到你在询问什么。术语 'hierarchy' 通常在传统的 OOP 术语中使用,并且在 JavaKotlin Android 中也得到支持:你可以创建一个 BaseActivity(),然后扩展它以用于 LoginActivityHomePageActivity

英文:

Activities are organised in the stack. Each Activity you have been opened is put on the top of this stack.

Android supports modification of such behaviour, e.g. newly opened Activity is put in the new stack. To learn more about possible options check this official docs.

A case of multi-window mode requires more investigation.

From your question I understand what you have been asking about. The term 'hierarchy' is usually used in traditional terms of OOP and it is also supported in both Java or Kotlin Android: you could create a BaseActivity() and extend it for both LoginActivity and HomePageActivity.

huangapple
  • 本文由 发表于 2023年6月15日 02:53:04
  • 转载请务必保留本文链接:https://go.coder-hub.com/76476730.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定