求android老手指导。。

============问题描述============


我在一个Acitivity里面写了多个Fragment.。有好几层的fragment在跳转,但是我一按手机上的回退键就把当前的Activity关掉了,也就是fragment全部都被关掉了。我想实现当按回退的时候返回到上一个fragment。。请问能否实现?该如何实现?

============解决方案1============


Before you call commit(), however, you might want to call addToBackStack(), in order to add the transaction to a back stack of fragment transactions. This back stack is managed by the activity and allows the user to return to the previous fragment state, by pressing the Back button.
posted @ 2014-10-18 22:24  android开发视频教程  阅读(98)  评论(0编辑  收藏  举报
我要啦免费统计