getView メソッドで BaseAdapter のレイアウトを拡張していて、返されたビューを convertView に渡すため、「面白い」問題が発生しました。面白いことに、convertView は null のままです。
convertView = myInflater.inflate(R.layout.customadapter_view_layout_medium, parent);
私はデバッグに行きました:
すべてが彼の正しい参照を得ました。親は GridView を参照しています。myInflater は null ではありません。インフレートするレイアウトの ID も存在します。ただし、convertView は null のままです。
これは私のlogCatです:
11-25 18:29:38.711: E/AndroidRuntime(2377): FATAL EXCEPTION: main
11-25 18:29:38.711: E/AndroidRuntime(2377): java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.widget.AdapterView.addView(AdapterView.java:477)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.LayoutInflater.inflate(LayoutInflater.java:497)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
11-25 18:29:38.711: E/AndroidRuntime(2377): at com.android.faccess.NewCustomAdapter.getView(NewCustomAdapter.java:87)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.widget.AbsListView.obtainView(AbsListView.java:2159)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.widget.GridView.onMeasure(GridView.java:1040)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.View.measure(View.java:15513)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:645)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:425)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.View.measure(View.java:15513)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.View.measure(View.java:15513)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.View.measure(View.java:15513)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4827)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
11-25 18:29:38.711: E/AndroidRuntime(2377): at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2176)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.View.measure(View.java:15513)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1874)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1089)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1265)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:989)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4351)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.Choreographer.doCallbacks(Choreographer.java:562)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.Choreographer.doFrame(Choreographer.java:532)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.os.Handler.handleCallback(Handler.java:725)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.os.Handler.dispatchMessage(Handler.java:92)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.os.Looper.loop(Looper.java:137)
11-25 18:29:38.711: E/AndroidRuntime(2377): at android.app.ActivityThread.main(ActivityThread.java:5039)
11-25 18:29:38.711: E/AndroidRuntime(2377): at java.lang.reflect.Method.invokeNative(Native Method)
11-25 18:29:38.711: E/AndroidRuntime(2377): at java.lang.reflect.Method.invoke(Method.java:511)
11-25 18:29:38.711: E/AndroidRuntime(2377): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
11-25 18:29:38.711: E/AndroidRuntime(2377): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
11-25 18:29:38.711: E/AndroidRuntime(2377): at dalvik.system.NativeStart.main(Native Method)
この行が UnsupportedOperationException をスローする理由を教えてください。どんな助けでも大歓迎です。