Android:倾斜移动设备会使 ImageView 内容消失/URI 刷新
预先感谢您的任何回复。我面临着一个相当微不足道的问题。 硬件:摩托罗拉(Android 手机)
我正在图像视图中显示图像。图像本身是通过 ContentResolver 从 URI 中获取的。问题是,每当我倾斜手机时,图像视图就会变成空白。通过跟踪日志和变量,我发现每当我倾斜手机时,相关 URI 都会返回到其默认(即 null)值。
当然有一个解决方法,即使用静态变量。但我想知道是否还有另一种解决方案,因为我真的很想在函数中传递 URI,以便对我的应用程序执行我想要的操作。
有谁知道发生了什么事吗?
问候。
Thank you in advance for any responses. I am facing rather a trivial problem.
Hardware: Motorola (Android phone)
I am displaying an image in an imageview. The image itself is grabbed off a URI via ContentResolver. The problem is that whenever I tilt my mobile, the imageview gets blank. By tracing the log and variables I found out that the relevant URI goes back to its default (i.e. null) value whenever I tilt the mobile.
Of course there is a workaround for it i.e. using static variables. But I am wondering if there is another solution since I would really like to pass the URIs around in functions to do what I desire with my application.
Does anyone know what's going on?
Regards.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
每当方向在纵向和横向之间变化时,您的 Activity 就会自动重新启动。查看两个 文章 了解处理此问题的方法。
Your activity is restarted automatically whenever the orientation changes between portrait and landscape. Check out these two articles for ways to handle this.