【发布时间】:2011-09-11 20:01:54
【问题描述】:
我试图弄清楚如何设置列表中 ratingBar 的值,但无法弄清楚。
我目前正在使用一个简单的适配器来设置文本。
其中 mylist 是一个哈希图。
ListAdapter adapter = new SimpleAdapter(this, mylist , R.layout.list_simple,
new String[] { "name"},
new int[] { R.id.item_title});
setListAdapter(adapter);
还有我的 xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:background="@color/white">
<TextView
style="@style/ListHeading"
android:id="@+id/item_title"
android:gravity="left"/>
<RatingBar
style="@style/RatingBarSm"
android:id="@+id/ratingBar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:isIndicator="true"/>
</LinearLayout>
当我尝试将“评级”添加到简单适配器时,我收到此错误。
ERROR/AndroidRuntime(10793): java.lang.IllegalStateException: android.widget.RatingBar is not a view that can be bounds by this SimpleAdapter
我还没有找到任何有用的东西。非常感谢任何帮助或指导。
【问题讨论】:
-
运气好吗?可能需要一个自定义列表适配器。
-
我也在想同样的事情,但还没试过
-
我必须制作一个扩展 simpleadapter 的自定义适配器
标签: android simpleadapter