0

ここで私は baseadapter を拡張し、すべてのデータをリストビューに表示するように設定し、リストビューからデータを検索したいコードを書いています

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);*/


                    }
4

0 に答える 0