SimpleAdapter支持的控件:checkbox、radiobutton、textview、imageview,也就是说如果在simpleadapter用到改变值时,只能放入这几种控制,而其它的控件不支持
其它控制不支持时,我们可以重载getView对其事件进行相应的捕获,如下:
<ListView
android:id="@+id/data"
style="@style/layout_list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="false"
android:layout_weight="1" />
SimpleAdapter mDataAdapter = new SimpleAdapter(this, mData,
R.layout.apprec_item,
new String[] { "icon", "name_only", "name", "desc" },
new int[] { R.id.icon, R.id.name_only, R.id.name, R.id.desc }) {
@Override
public View getView(final int position, final View convertView,
final ViewGroup parent) {
View view = super.getView(position, convertView, parent);
View vAction = view.findViewById(R.id.action);
vAction.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
onActionClick(position);
}
});
return view;
}
};
mDataView.setAdapter(mDataAdapter);