这是我的LazyAdapter
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解析中获取数据。