如何使用Android后退按钮在我的应用程序中移回来,而不是关闭我的应用程序? [英] How can I use the Android back button to move back within my app instead of closing my app?

查看:92
本文介绍了如何使用Android后退按钮在我的应用程序中移回来,而不是关闭我的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序有三个活动,A,B和C.我通过一个确定按钮从A到B,我想通过使用Android设备的默认后退按钮从B回到A。当我按下按钮,虽然,整个应用程序被关闭。

My app has three activities, A, B and C. I am moving from A to B through an OK button, and I want to move back from B to A by using the default back button of Android devices. When I press the button, though, the entire app gets closed. How can I get around this problem?

推荐答案

我怀疑你调用 finish()在你的OK按钮onclick监听器。不要这样做。 finish()从活动堆栈中移除您的活动。

I suspect you call finish() in your OK button onclick listener. Don't do that. finish() removes your activity from activity stack.

阅读更多此处

这篇关于如何使用Android后退按钮在我的应用程序中移回来,而不是关闭我的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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