performFiltering()!
java.lang.ClassCastException:无法转换android.graphics.Bitmap 到java.lang.String
我的代码就是这个
adapter = new SimpleAdapter(
getActivity(), contactList,
R.layout.list_item, new String[]{TAG_USERNAME,TAG_Age,TAG_SPECIALITY,TAG_CITY,TAG_COUNTRY,TAG_IMAGE}, new int[]{R.id.USERNAME, R.id.AGE, R.id.SPECIALITY, R.id.City, R.id.Country, R.id.Image}
);
adapter.setViewBinder(new SimpleAdapter.ViewBinder() {
@Override
public boolean setViewValue(View view, Object data,
String textRepresentation) {
if ((view instanceof ImageView) & (data instanceof Bitmap)) {
ImageView iv = (ImageView) view;
Bitmap bm = (Bitmap) data;
iv.setImageBitmap(bm);
return true;
}
return false;
}
});
setListAdapter(adapter);
/**
* Enabling Search Filter
* */
inputSearch.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
// When user changed the Text
try {
if (adapter != null) {
ChefFragment.this.adapter.getFilter().filter(cs);
} else {
Log.d("filter", "no filter availible");
}
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable arg0) {
// TODO Auto-generated method stub
}
});
答案 0 :(得分:0)
我假设您在比较器中将搜索字符串与位图图像进行比较,这是不可能的。