2011-11-08 58 views
0

我在Activity上有這段代碼,我回頭再看這個活動並更新ArrayList數據。更新微調錯誤

{ArrayAdapter<String> adaptador =  
    new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item, datos); 

spinnerD = (Spinner)findViewById(R.id.spinner1); 

adaptador.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); 
spinnerD.setAdapter(adaptador); 

當我試圖「重啓」我收到以下錯誤的活動後,打開微調:

11-08 04:13:14.313: ERROR/AndroidRuntime(272): FATAL EXCEPTION: main 
11-08 04:13:14.313: ERROR/AndroidRuntime(272): java.lang.NullPointerException 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.widget.ArrayAdapter.createViewFromResource(ArrayAdapter.java:355) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.widget.ArrayAdapter.getDropDownView(ArrayAdapter.java:376) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.widget.Spinner$DropDownAdapter.getDropDownView(Spinner.java:329) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.widget.Spinner$DropDownAdapter.getView(Spinner.java:325) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.widget.AbsListView.obtainView(AbsListView.java:1294) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.widget.ListView.measureHeightOfChildren(ListView.java:1198) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.widget.ListView.onMeasure(ListView.java:1109) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.view.View.measure(View.java:8171) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1012) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.widget.LinearLayout.measureVertical(LinearLayout.java:381) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.widget.LinearLayout.onMeasure(LinearLayout.java:304) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.view.View.measure(View.java:8171) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1012) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.widget.LinearLayout.measureVertical(LinearLayout.java:381) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.widget.LinearLayout.onMeasure(LinearLayout.java:304) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at com.android.internal.widget.WeightedLinearLayout.onMeasure(WeightedLinearLayout.java:60) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.view.View.measure(View.java:8171) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:245) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.view.View.measure(View.java:8171) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3132) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:245) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.view.View.measure(View.java:8171) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.view.ViewRoot.performTraversals(ViewRoot.java:801) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.view.ViewRoot.handleMessage(ViewRoot.java:1727) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.os.Handler.dispatchMessage(Handler.java:99) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.os.Looper.loop(Looper.java:123) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at android.app.ActivityThread.main(ActivityThread.java:4627) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at java.lang.reflect.Method.invokeNative(Native Method) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at java.lang.reflect.Method.invoke(Method.java:521) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) 
11-08 04:13:14.313: ERROR/AndroidRuntime(272):  at dalvik.system.NativeStart.main(Native Method) 
11-08 04:13:16.052: ERROR/MetadataRetrieverClient(33): failed to extract an album art 
+0

你有沒有使用過spinnerD.setAdapter(adaptador); ?另外,哪行代碼是355? –

+0

該錯誤甚至不是一個錯誤,只是對一行代碼的引用。什麼是完整的錯誤文本 – MrZander

回答

2
spinnerD.setAdapter(adaptador1); 

是什麼adaptador1,要創建「adaptador」,然後你將adaptador1設置爲您的spinnerD.setAdapter(adaptador1)。它是否正確 ? 'adaptador1'可能爲空/空。

+0

你是說它應該是空的或者是空的,這就是爲什麼我有錯誤?在我做spinnerD.setAdapter(adaptador)之前,adaptador並不是空的。 –