我正在尝试向我的row.xml视图添加一个ProgressBar,但是我似乎不能让它工作,我一直得到
06-09 12:44:44.802: ERROR/AndroidRuntime(1012): java.lang.IllegalStateException: android.widget.ProgressBar is not a view that can be bounds by this SimpleAdapter
ArrayList arr = new ArrayList();
HashMap map = new HashMap();
map.put("progress", 10);
arr.add(map);
String [] fieldNames = {"progress"};
int [] fieldIds = {R.id.progress};
SimpleAdapter adapter = new SimpleAdapter(this, arr, R.layout.row, fieldNames, fieldIds);
list = (ListView) findViewById(R.id.list);
list.setAdapter(adapter);
<ProgressBar android:id="@+id/progress"
style="?android:attr/progressBarStyleHorizontal"
android:max="100"
android:progress="5"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>有人知道我错过了什么吗?
发布于 2010-06-09 19:03:58
SimpleAdapter不知道如何处理ProgressBar。此外,ProgressBar本身将是一个真正糟糕的列表行。
请将ProgressBar放在较大的行布局中(带有标签等)。您还需要创建自己的适配器类,该类将知道如何将数据绑定到ProgressBar。
发布于 2011-10-14 02:21:50
您还可以使用SimpleAdapter.setViewBinder()并绑定SimpleAdapter.ViewBinder中的进度条。这使您可以将内置的SimpleAdapter功能用于其他字段。
https://stackoverflow.com/questions/3003141
复制相似问题