当进度条在android中旋转时如何停止改变方向
我有一个注册屏幕,用户在其中输入所有注册详细信息,当用户单击“注册”按钮时,我显示进度条(进度条开始旋转),然后将用户带到主屏幕。如果用户旋转当进度条旋转时,手机会关闭进度条。当进度条可见时(意味着它正在旋转),我希望方向不要从纵向更改为横向,反之亦然。如何在进度条时停止方向更改正在旋转?有什么帮助吗赞赏。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
发生这种情况是因为当屏幕方向旋转时,活动会重新启动。在这种情况下,您可以在 AndroidManifest 文件的标记中添加 configChanges 属性来停止重新创建 Activity。
这样,如果进度条正常工作,您的方向就会改变,而且即使方向改变,它也不会停止。
更新
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.By, this your orientation can change will the progress bar is working and also it won't stop though the orientation changes.
UPDATE
正如此处所解释的,调用
然后
真正就像魅力一样...在真实设备上!
不要认为在模拟器上测试时它已损坏,ctrl+F11 快捷键始终会更改屏幕方向,而不模拟传感器移动。
其他一些参考:
这是Activityinfo
************* **** 已编辑 ********************************
我认为你无法处理进度条在屏幕旋转上。 我说得对吗?
因此,您无需为此解决方案停止轮换。您应该处理进度条。
这里有一些教程,对于此目的很有用..
************** 已编辑 2 ******************
有时,当方向改变时,您会丢失数据。因此,您可以尝试这些教程
As explained here, calling
and then
really works like charm... on real devices !
Don't think that it's broken when testing on the emulator, the ctrl+F11 shortcut ALWAYS change the screen orientation, without emulating sensors moves.
Some other references :
And here is Activityinfo
***************** Edited ********************************
And I think you are not able to handle progressbar on screen rotation. Am I right?
So you need not to stop the rotation for this solution. You should handle the progress bar.
Here are some tutorials, which are useful for this purpose ..
************** Edited 2 *****************
And some time you looses data when orientation changes. So you can try these tutorials
在 Activity 类中使用 setRequestOrientation 方法。
继承ProgressDialog类,并重写方法。
示例代码如下。
use setRequestOrientation method in Activity class.
Inherit ProgressDialog class, and override methods.
Example code is below.