这里我正在编写代码我在其中扩展了baseadapter并且我已经设置了要在listview上显示的所有数据,我想从listview中搜索数据
public class Listadapter extends BaseAdapter {
public Listadapter() {
super();
}
public int getCount() {
return productList.size();
}
public long getItemId(int position) {
return productList.indexOf(getItem(position));
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
LayoutInflater inflator = ProductList.this.getLayoutInflater();
TextView txtprodName, txtcategory, txtOfferDate;
ImageView ProductImage;
convertView = inflator.inflate(R.layout.product_list_item, null);
txtprodName = (TextView) convertView.findViewById(R.id.txtprodName);
txtcategory = (TextView) convertView.findViewById(R.id.txtcategory);
txtOfferDate = (TextView) convertView.findViewById(R.id.txtOfferDate);
ProductImage = (ImageView) convertView.findViewById(R.id.ProductImage);
HashMap<String, String> hm = productList.get(position);
//txtUserName.setText(lstUsers.get(position).getFirst_Name()+" "+lstUsers.get(position).getLast_Name());
txtprodName.setText(hm.get(TAG_PRODUCT_NAME));
txtcategory.setText(hm.get(TAG_CATEGORY_NAME));
txtOfferDate.setText(hm.get(TAG_OFFER_START_TIME));
if(drawable.get(position)!=null)
ProductImage.setImageDrawable(drawable.get(position));
else
ProductImage.setImageResource(R.drawable.nopic_place);
return convertView;
}
@Override
public Object getItem(int arg0) {
// TODO Auto-generated method stub
return null;
}
}
现在如何在OnTextChanged()中调用listadapter进行过滤并通过它进行搜索...我已经使用简单的适配器完成了这个...但是它正在用baseadapter创建问题
lstProductList.setAdapter(new Listadapter());
inputSearch.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence cs, int arg1,
int arg2, int arg3) {
// When user changed the Text
/*( (SimpleAdapter) lstProductList.getAdapter()).getFilter().filter(
cs);*/
}