0
對於我的業務,另一位開發人員和我自己正在開發移動文本和語音應用程序。我們希望將一堆切換小部件作爲「設置」頁面添加到我們的一個頁面。但是,當我在調試器仿真器上運行它時,我得到一個空指針錯誤,沒有關於問題的信息。我們能夠確定它是不可用的符號,因爲我的開發人員運行相同的代碼,得到的文本顯示,但該符號仍然沒有顯示。但是他沒有得到同樣的錯誤。Xamarin - Android應用程序開發 - 開關圖標丟失並導致NullPointer
爲了進一步測試,我創建了一個空白項目,將Switch添加到相同的樣式佈局,並且沒有任何問題地運行它。
我只在佈局的XML中添加開關。
有沒有一種方法可以修復/添加圖像以刪除空指針?謝謝!
編輯:一個錯誤日誌中我收到:
W/dalvikvm(1965): threadid=1: thread exiting with uncaught exception(group=0xa8cbbb20)
Unhandled Exception:
Java.Lang.NullPointerException:
06-27 16:49:39.449 E/AndroidRuntime(1965): FATAL EXCEPTION: main
06-27 16:49:39.449 E/AndroidRuntime(1965): Process: SecureMobileApp.Droid, PID: 1965
06-27 16:49:39.449 E/AndroidRuntime(1965): java.lang.NullPointerException
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.widget.Switch.jumpDrawablesToCurrentState(Switch.java:825)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5488)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5488)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.widget.FrameLayout.jumpDrawablesToCurrentState(FrameLayout.java:189)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5488)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5488)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.widget.FrameLayout.jumpDrawablesToCurrentState(FrameLayout.java:189)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5488)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.view.ViewGroup.jumpDrawablesToCurrentState(ViewGroup.java:5488)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.widget.FrameLayout.jumpDrawablesToCurrentState(FrameLayout.java:189)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.view.View.onAttachedToWindow(View.java:12116)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.view.ViewGroup.onAttachedToWindow(ViewGroup.java:3497)
06-27 16:49:39.449 E/AndroidRuntime(1965): at com.android.internal.policy.impl.PhoneWindow$DecorView.onAttachedToWindow(PhoneWindow.java:2659)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.view.View.dispatchAttachedToWindow(View.java:12585)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.view.ViewGroup.dispatchAttachedToWindow(ViewGroup.java:2458)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1213)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5600)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.view.Choreographer.doCallbacks(Choreographer.java:574)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.view.Choreographer.doFrame(Choreographer.java:544)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.os.Handler.handleCallback(Handler.java:733)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.os.Handler.dispatchMessage(Handler.java:95)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.os.Looper.loop(Looper.java:136)
06-27 16:49:39.449 E/AndroidRuntime(1965): at android.app.ActivityThread.main(ActivityThread.java:5001)
06-27 16:49:39.449 E/AndroidRuntime(1965): at java.lang.reflect.Method.invokeNative(Native Method)
06-27 16:49:39.449 E/AndroidRuntime(1965): at java.lang.reflect.Method.invoke(Method.java:515)
06-27 16:49:39.449 E/AndroidRuntime(1965): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
06-27 16:49:39.449 E/AndroidRuntime(1965): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
06-27 16:49:39.449 E/AndroidRuntime(1965): at dalvik.system.NativeStart.main(Native Method)
你可以添加相關的代碼片段,錯誤日誌和你試過的東西嗎?理想情況下,這聽起來像你根本沒有設置任何東西,它將作爲NRE出現。 –
switch * statement *是一個C#構造;一個Switch * widget *是一個Android UI控件。我假設你的意思是後者,但你的問題具體說「聲明」 – Jason
對不起傑森,謝謝你的抓住 –