问题描述
我目前正在处理我们的最终项目。我的问题是其他活动中的“后退”按钮的功能是关闭应用而不是返回上一个活动。
这是一项活动的有效“返回”按钮
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestwindowFeature(Window.FEATURE_NO_TITLE);
this.getwindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
getSupportActionBar().hide(); // hides the action bar.
setContentView(R.layout.activity_mm_about_us);
ImageButton imgbtn_AU_Back = findViewById(R.id.imgbtn_AU_Back);
imgbtn_AU_Back.setonClickListener(v -> finish()); // when the "Back" button is clicked,you will return to the prevIoUs activity / screen.
}
这是我的一项活动中错误的“返回”按钮
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestwindowFeature(Window.FEATURE_NO_TITLE);
this.getwindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
getSupportActionBar().hide(); // hides the action bar.
setContentView(R.layout.activity_mm_settings);
ImageButton imgbtn_About_Us = findViewById(R.id.imgbtn_About_Us);
ImageButton imgbtn_ST_Back = findViewById(R.id.imgbtn_ST_Back);
imgbtn_About_Us.setonClickListener(new View.OnClickListener() { // "About Us" screen will be shown when the image button is clicked.
@Override
public void onClick(View v) {
startActivity(new Intent(getApplicationContext(),MM_AboutUs.class));
}
});
imgbtn_ST_Back.setonClickListener(v -> finish()); // when the "Back" button is clicked,you will return to the prevIoUs activity / screen.
}
希望你能解决我的问题。永远保持安全,我的程序员伙伴们。
- 申请流程*
A) 登录屏幕(父活动)
B) 注册屏幕/活动(儿童)
C) 主菜单屏幕/活动(父)
- 个人资料按钮 -> 个人资料屏幕/活动(子)
- 设置按钮 -> 设置/活动(子项)
- 其他按钮(子)
D) 设置屏幕/活动(父)
E) 关于屏幕
- 返回按钮 -> 设置(工作)
F) 个人资料屏幕
转到个人资料法案
imgbtn_Profile.setonClickListener(v -> {
startActivity(new Intent(getApplicationContext(),MM_Profile.class));
finish();
});
这是Profile Activity中返回按钮的“返回”功能
btn_PR_Back.setonClickListener(v -> finish());
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)