Android 自定义 Spinner Row(照片+字符串)

发布于 2024-12-08 19:17:41 字数 4325 浏览 2 评论 0原文

我有这个文件:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文