这是我的懒惰适配器
public class LazyAdapter extends BaseAdapter {
private Activity activity;
private ArrayList<HashMap<String, String>> data;
private static LayoutInflater inflater=null;
private Context mCtx;
public LazyAdapter(Activity a, ArrayList<HashMap<String, String>> d,Context context) {
activity = a;
data=d;
inflater = (LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
mCtx = context;
}
public int getCount() {
return data.size();
}
public Object getItem(int position) {
return position;
}
public long getItemId(int position) {
return position;
}
public View getView(int position, View convertView, ViewGroup parent) {
View vi=convertView;
if(convertView==null)
vi = inflater.inflate(R.layout.list_item, null);
TextView name = (TextView)vi.findViewById(R.id.name); // name
TextView desc = (TextView)vi.findViewById(R.id.desciption); // collection
TextView cost = (TextView)vi.findViewById(R.id.cost); // cost
TextView category = (TextView)vi.findViewById(R.id.txtcategory); // cost
TextView spec = (TextView)vi.findViewById(R.id.txtspec); // cost
TextView largeimg = (TextView)vi.findViewById(R.id.txtlargeimage); // cost
ImageView thumb_image=(ImageView)vi.findViewById(R.id.ivcatalouge); // thumb image
HashMap<String, String> song = new HashMap<String, String>();
song = data.get(position);
// Setting all values in listview
name.setText(song.get(FrmShowCatlogue.KEY_MODEL));
desc.setText(song.get(FrmShowCatlogue.KEY_COLLECTION));
cost.setText(song.get( FrmShowCatlogue.KEY_MRP));
category.setText(song.get( FrmShowCatlogue.KEY_CATEGORY));
spec.setText(song.get( FrmShowCatlogue.KEY_SPEC));
largeimg.setText(song.get( FrmShowCatlogue.KEY_LARGE));
largeimg.setVisibility(View.GONE);
try
{
String filename=song.get(FrmShowCatlogue.KEY_IMAGES.toString());
filename="thumbs/" + filename;
// get input stream
InputStream ims = mCtx.getAssets().open(filename);
// load image as Drawable
Drawable d = Drawable.createFromStream(ims, null);
// set image to ImageView
thumb_image.setImageDrawable(d);
}
catch(IOException ex)
{
//thumb_image.setVisibility(View.GONE);
}
return vi;
}
}
我想对具有lazyadapter的自定义列表视图执行过滤器。我已经做了
inputSearch.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
// When user changed the Text
//FrmShowCatlogue.this.adapter.getFilter().filter(cs);
}
@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
}
});
请帮助对我的lazyadapter 执行过滤器。Lazyadapter 正在从 xml 解析中获取数据。