Android 应用旋转器和方向更改中出现意外崩溃
首先,这是我的第一个应用程序,我对 Android 应用程序有非常基本的了解。
我的第一个问题是屏幕方向改变的问题。我已经看到这个问题在这里被问了一百万次,但我不太明白答案,我不确定是否是同样的情况。当屏幕方向改变时,我的应用程序崩溃。我没有像很多问题提到的那样使用 ViewFlipper。当您尝试滚动浏览微调器中的选项时,我的应用程序也会崩溃。微调器已正确填充,您可以打开它并选择一个选项,但滚动或打开它并多次更改选择会导致崩溃。我认为我最大的问题是我不习惯 Eclipse IDE 或 java(我主要是一个 .net 开发人员),我觉得它崩溃时让我完全蒙在鼓里。它只说“未找到来源”。这对我没有多大帮助。
所以我想我的问题是:有谁知道什么会导致应用程序在这两个实例中崩溃和/或当它只是说“未找到源”时我该如何调试问题?
To preface this question, this is my first app and I have a very basic understanding of android apps.
My first problem is the issue with screen orientation change. I've seen this question asked on here a million times, but I don't really understand the answers and I'm not sure if it is the same situation or not. My app crashes when the screen orientation changes. I am not using ViewFlipper as a lot of the questions mention. My app also crashes when you try to scroll through the options in a spinner. The spinner is populated correctly, and you can open it and select an option, but scrolling or opening it and changing selection multiple times causes a crash. I think my biggest problem here is I am not used to the Eclipse IDE or java (I am a .net developer primarily) and I feel like it leaves me completely in the dark when it crashes. All it ever says is "Source not found". That doesn't help me much.
So I guess my question is: does anyone know what would cause the application to crash in either of these two instances and/or how do I go about debugging the issues when it simply says "source not found"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我弄清楚了这些问题。无论如何。
微调器崩溃是由我绑定为源的数组中的空值引起的。所以那是我的错。
方向崩溃是由...引起的,我不太确定。但为了进行调查,我将
android:configChanges="orientation"
插入清单中,以便能够处理onConfigurationChanged
事件。我插入了代码来覆盖该方法,问题完全停止了。这是完全解决问题所需的代码。我不知道是什么原因导致了这个问题,也不知道为什么会解决这个问题,所以如果有人能解释一下,请发表评论!
I figured out the issues. Sort of anyways.
The spinner crash was caused by a null value in the array I was binding as the source. So that one was my fault.
The orientation crash was caused by... I'm not really sure. But to investigate I inserted
android:configChanges="orientation"
into the manifest to be able to handle theonConfigurationChanged
event. I inserted the code to override the method and the problem stopped completely.That is the code necessary to fix the problem in it's entirety. I have no idea what was causing the problem or why that fixed it so if anyone can shed some light please comment!