简体   繁体   English

Android开发中Unwind segue的等效之处

[英]What is equivelant of Unwind segue in Android Development

I am used to IOS development and there are unwind segues in Swift to exit to a certain view controller from the present view controller. 我已经习惯了IOS开发,在Swift中有一些轻松的任务可以从当前的视图控制器退出到某个视图控制器。

(If there is any) What is equivelant of Unwind segue in Android Development? (如果有的话)Android开发中Unwind segue的等效功能是什么? What should I do to go back to a certain activity? 我该怎么做才能返回某项活动?

This is handled in onBackPressed() of your Activity, which you can override if you want to do anything special. 这是在onBackPressed()中处理的,如果您想做任何特殊的事情,可以重写它。 If you want finer control or more detail, you can read up on FragmentManager , which manages the backstack. 如果您想要更好的控制或更多细节,可以在FragmentManager上进行阅读,该FragmentManager管理后台堆栈。 popBackStack() and popBackStackImmediate() may be what you're looking for. 您正在寻找popBackStack()popBackStackImmediate() Generally you shouldn't have to micromanage this too much. 通常,您不必对此进行过多的微管理。 By default it'll take you back to the previous activity with no effort on your part. 默认情况下,您无需费力即可回到上一个活动。

One thing to take note of as an iOS dev jumping into Android, is there's a difference between back (the button at the bottom), and up (the button in the toolbar up top). iOS开发人员跳入Android时要注意的一件事是, back (底部的按钮)和up back (顶部工具栏中的按钮)之间存在差异。 The back button takes you back to the previous screen you saw(even to other apps), closes the keyboard, or dismisses certain windows. “后退”按钮可将您带回到您看到的上一个屏幕(甚至是其他应用程序),关闭键盘或关闭某些窗口。 The up button basically returns you to the main screen of the app, popping the whole backstack. 向上按钮基本上可以使您返回到应用程序的主屏幕,并弹出整个后退堆栈。 There's some fine points here, which Google does an excellent job explaining in the design guidelines . 这里有一些要点,Google在设计指南中做了出色的解释。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM