在Android的退出按钮不工作 [英] exit button in android not working

查看:241
本文介绍了在Android的退出按钮不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图关闭应用程序按钮的点击click.so我用下面的code主页上

I was trying to close app on click of button click.so i use the following code on home page

closebtn.setOnClickListener(new OnClickListener() 
        {

            @Override
            public void onClick(View v) 
            {
                // TODO Auto-generated method stub
                finish();
            }
        });

第5页 打开关闭按钮的点击主页。

from page5 clicking of close button Home page opens.

b5.setOnClickListener(new OnClickListener() 
        {

            @Override
            public void onClick(View v) 
            {
                // TODO Auto-generated method stub
                Intent i =new Intent(Page5.this, FirstPage.class);
                startActivity(i);
            }
        });

所以,当我在主页上的关闭按钮单击它再次将改为第5页关闭应用程序。

so when i click on close button in home page it is again going to page5 instead of closing app.

请帮我找到了问题

先谢谢了。

推荐答案

完成()不会关闭该应用程序。它仅关闭当前活动。因此,在完成自然的行为是回到活动堆栈的最后一项活动活动了。

finish() doesn't close the app. It only closes the current activity. So after finishing an activity the natural behavior is going back to the last activity of activity stack.

所以,现在你有多个选项

So now you have multiple options


  1. 在开始下一个之前完成previous活动

  2. startactivityforresult启动第二个活动。完成后,你可以赶上的onActivityResult完成。

还有其他可能的选择。

这篇关于在Android的退出按钮不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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