如何停止切换时的进度条中纺机器人的方向中纺、机器人、进度条、方向

2023-09-12 08:10:33 作者:铁打的心隨便傷

我在那里用户输入的所有登记内容和登记屏幕时,用户点击注册按钮,我显示进度条(进度条开始旋转),然后把用户带到家里screen.If的用户旋转手机时,进度条是纺纱,进度条得到dismissed.I所需的方向不改变从potrait景观,反之亦然,当进度条是可见的(这意味着它旋转)。如何停止的方向变化当进度条纺?任何帮助将是AP preciated。

I have a Registration screen where user enters all the registration details and when user clicks on the "Register" button i am showing the progress bar(Progress bar begins to spin) and then takes the user to the home screen.If the user rotates the phone when progress bar is spinning, the progress bar gets dismissed.I want the orientation not to change from potrait to landscape and vice versa,when a progress bar is visible(meaning it is spinning).How to stop the orientation change when progress bar is spinning?Any help would be appreciated.

推荐答案

这是由于发生时,屏幕方向旋转活动被重新启动。在这种情况下,你可以在AndroidManifest文件在您添加标记 configChanges 属性停止再创造活动的。

This is happening because when screen orientation rotates the Activity gets re-started. In this case you can add configChanges attribute in your tag in the AndroidManifest file to stop the re-creation of the Activity.

<activity android:name=".Activity_name"
          android:configChanges="orientation|keyboardHidden">

通过,这是你的取向可以改变将进度条的工作,也不会停止,虽然方向发生变化。

By, this your orientation can change will the progress bar is working and also it won't stop though the orientation changes.

更新

@Override
    public void onConfigurationChanged(Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        if(newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE){
            setContentView(R.layout.login_landscape);
        }
        else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
            setContentView(R.layout.login);         
        }
    }