Android 自定义 Spinner Row(照片+字符串)
我有这个文件:
1- Option.java => myActivity
2- CurrencyAdapterList => where i have defined myAdapter for the spinner
3- SpinnerCurrRow => where I have defined the object that contain photo+string that will be displayed in a spinner row
4- spnrow.xml => layout of a spinner row
5- frmconfig.xml => layout of Option.java activity
这是代码:
1- http://ideone.com/8hg93
2- http://ideone.com/N8Xu4
3- http://ideone.com/VMMSX
4- http://ideone.com/mumbn
5- http://ideone.com/f69zF
微调器已正确填充,但问题是,如果我单击微调器来选择记录,我会返回 nullpointException
10-07 11:12:15.813: ERROR/AndroidRuntime(996): FATAL EXCEPTION: main
10-07 11:12:15.813: ERROR/AndroidRuntime(996): java.lang.NullPointerException
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.ListView.measureScrapChild(ListView.java:1135)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.ListView.measureHeightOfChildren(ListView.java:1218)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.ListView.onMeasure(ListView.java:1127)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.View.measure(View.java:8313)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.View.measure(View.java:8313)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at com.android.internal.widget.WeightedLinearLayout.onMeasure(WeightedLinearLayout.java:60)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.View.measure(View.java:8313)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.View.measure(View.java:8313)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.View.measure(View.java:8313)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.ViewRoot.performTraversals(ViewRoot.java:839)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.os.Handler.dispatchMessage(Handler.java:99)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.os.Looper.loop(Looper.java:123)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at java.lang.reflect.Method.invokeNative(Native Method)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at java.lang.reflect.Method.invoke(Method.java:507)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at dalvik.system.NativeStart.main(Native Method)
我不明白我做错了什么。 谁能帮助我吗? 太感谢了。
I have this files:
1- Option.java => myActivity
2- CurrencyAdapterList => where i have defined myAdapter for the spinner
3- SpinnerCurrRow => where I have defined the object that contain photo+string that will be displayed in a spinner row
4- spnrow.xml => layout of a spinner row
5- frmconfig.xml => layout of Option.java activity
Here is the code:
1- http://ideone.com/8hg93
2- http://ideone.com/N8Xu4
3- http://ideone.com/VMMSX
4- http://ideone.com/mumbn
5- http://ideone.com/f69zF
The spinner is correctly populated but the problem is that if I click on the spinner for choose a record I have returned a nullpointException
10-07 11:12:15.813: ERROR/AndroidRuntime(996): FATAL EXCEPTION: main
10-07 11:12:15.813: ERROR/AndroidRuntime(996): java.lang.NullPointerException
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.ListView.measureScrapChild(ListView.java:1135)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.ListView.measureHeightOfChildren(ListView.java:1218)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.ListView.onMeasure(ListView.java:1127)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.View.measure(View.java:8313)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.View.measure(View.java:8313)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at com.android.internal.widget.WeightedLinearLayout.onMeasure(WeightedLinearLayout.java:60)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.View.measure(View.java:8313)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.View.measure(View.java:8313)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.View.measure(View.java:8313)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.ViewRoot.performTraversals(ViewRoot.java:839)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.os.Handler.dispatchMessage(Handler.java:99)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.os.Looper.loop(Looper.java:123)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at android.app.ActivityThread.main(ActivityThread.java:3683)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at java.lang.reflect.Method.invokeNative(Native Method)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at java.lang.reflect.Method.invoke(Method.java:507)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
10-07 11:12:15.813: ERROR/AndroidRuntime(996): at dalvik.system.NativeStart.main(Native Method)
I don't understan what I am doing wrong.
Can anyone help me?
Thank you so much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论