简体   繁体   English

片段中的Android Back Stack

[英]Android Back Stack in fragments

Hi i an Question on BackStack, 嗨,我在BackStack上有一个问题, 在此处输入图片说明

in screen it should not back back from 3 to 2 screen on clicking back button on Android phone. 在屏幕上,在Android手机上单击“后退”按钮时,不应从3到2屏幕退回。

but inside the 3 screen , first it will show home screen , then book and atlast xyz 但在3屏幕中,首先将显示主屏幕,然后预定并显示xyz

when e clik back in 3 screen it came to from xyz to books screen then to home screen finaly it should not go back to 2 screen . 当e clik返回3屏幕时,它从xyz转到书本屏幕,然后进入主屏幕最后,它不应返回2屏幕。

fragmentManager.beginTransaction()add(R.id.frame_container,fragment).addToBackStack(null).commit();

Username and password is Activity , 用户名和密码为Activity,

3-screen is FragmentActivty 3屏幕是FragmentActivty

When you are done with password activity.. you can simply add finish() statement before startActivity(Home) in this case it will be removed from the BackStack and when pressing back it will exit you from the application 完成密码活动后..您可以在startActivity(Home)之前简单地添加finish()语句,在这种情况下,它将从BackStack中删除,而按回时它将退出应用程序

so it should be something like this: 所以应该是这样的:

Intent i = new Intent(this, ..homeActivity.class);
finish();
startActivity(i);

same goes for username activity if you don't want to get back to it 如果您不想返回用户名活动,也是如此

If you do not want to retain the activities or fragment activities in backstack use noHistory in activity tag of your menifest. 如果您不想保留活动或将活动分段存储在后noHistory中,请在noHistory的活动标签中使用noHistory

    <activity
        android:name="YourActivityName"
        android:label="@string/app_name"
        android:noHistory="true" >
    </activity>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM