求android老手指导。。

时间:2014-10-18 23:39:06   收藏:0   阅读:291

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


我在一个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.

原文:http://www.cnblogs.com/llj1985522/p/4033853.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!