在应用程序中返回主屏幕的命令是什么?

发布于 2024-10-03 04:53:41 字数 140 浏览 10 评论 0原文

当用户处于不同班级并单击手机上的后退/返回按钮时,如何让应用程序返回“主”屏幕?

现在,当他们访问不同的类并点击后退按钮时,它会返回到 Droid 上的主屏幕,而不是应用程序上的主屏幕 - 我如何让它返回到应用程序上的主屏幕?

谢谢!

How do I have an app return to the 'Home' screen when the user is on a different class and they click the back/return button on their phone?

Right now, when they access a different class and hit the back button, it goes back to the Home screen on the Droid rather than the Home screen on the app - how do I get it to go back to the Home Screen on the app?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

垂暮老矣 2024-10-10 04:53:41

使用 Activity 类的 OnBackPressed() 方法。
设定如下条件:

public void onBackPressed(){    
if(conditon)
  {
    detailInfoList.setVisibility(View.VISIBLE);//or anything that you want to show
  }
}

Use OnBackPressed() method of Activity class.
Make conditions like :

public void onBackPressed(){    
if(conditon)
  {
    detailInfoList.setVisibility(View.VISIBLE);//or anything that you want to show
  }
}
甜味超标? 2024-10-10 04:53:41

你不能,

主页按钮是唯一无法阻止关闭应用程序的按钮。这样做是为了让您无法阻止应用程序内的用户(如病毒)。

其他键(例如后退菜单和研究)可以

在您的活动中使用

@Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if(event.getAction() == MotionEvent.ACTION_DOWN){
            if(keyCode == 82){
               Log.i("jason","released on menu");
               //change view
               //return so that the other behavior (leaving the activity) is not tirggered
               return false;
        }   
        }
        Log.i("jason","actual key code "+keyCode);
        return super.onKeyDown(keyCode, event);
    }

you can't,

the home button is the only you can't prevent form closing your app. Its done so that you can't block the user inside your applications (like a virus).

the other keys like back menu and research are possible

in your activity

@Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if(event.getAction() == MotionEvent.ACTION_DOWN){
            if(keyCode == 82){
               Log.i("jason","released on menu");
               //change view
               //return so that the other behavior (leaving the activity) is not tirggered
               return false;
        }   
        }
        Log.i("jason","actual key code "+keyCode);
        return super.onKeyDown(keyCode, event);
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文