Android的:如何模拟后退按钮 [英] Android: How to simulate back button

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

问题描述

目前我的活动允许用户填写了某些数据。其中包括微调等。当用户点击一次系统导航到另一个屏幕。当我preSS后退按钮上的电话previous活动加载,填补数据可用。

Currently my activity allows users to fill up certain data. Including spinner etc. When user click next system navigates to another screen. When I press back button on the phone previous activity loaded and filled data is available.

我的要求,要求我给柔和的后退按钮,在UI。当用户点击它它navigats回previous屏幕,但填充数据不可用。

My requirement asks me to give a soft "Back" button in the UI. When user clicks it it navigats back to previous screen but the filled data is not available.

有什么方法来模拟软UI按钮onclick事件?

Is there any way to simulate the back button on a soft UI button onclick event??

Intent back = new Intent(ImagePreviewActivity.this, sendingpage.class);
startActivity(back);

在此先感谢您的时间。

Thanks in advance for your time.

推荐答案

您只好打电话给你的活动 完成()当用户点击软后退按钮的方法。

You'll just have to call your Activity finish() method when the user clicks the soft back button.

编辑:只是让你的活动实施 OnClickListener ,然后在code

just let your Activity implement OnClickListener and then in code

          myBackButton.setOnClickListener(this);
   ....

   public void onClick(View v) {
       if(v.getId()==R.id.YourBackButton){
           finish();
       }
   }

EDIT2 :您也可以拨打 onBack pressed()活动

EDIT2: you can also call onBackPressed() from your Activity.

这篇关于Android的:如何模拟后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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