Skip to content Skip to sidebar Skip to footer

Android Listview Based On Simpleadapter Includes Image Descriptions When Searching Using Textwatcher

I have an android ListView hooked up to a Simpleadapter. It outputs specific static images as icons on the listview depending on text content of some elements as well as some text

Solution 1:

Here's the code I end up doing (thanks @Luksprog):

public void afterTextChanged(Editable s) {
    if(s.length()>0){
        int count = viewListAdapter.getCount();
        if(count > 0){
            hashMapListForListViewcopy.clear();
            for (int i = 0; i < count; i++) {
                Map temp = (Map) viewListAdapter.getItem(i);
                String txtOfferName = temp.get("txtOfferName").toString();
                HashMap<String, String> entitiesHashMap;
                entitiesHashMap = new HashMap<String, String>();
                if (txtOfferName.toLowerCase().contains(s.toString().toLowerCase())) {
                    System.out.println("Found a match!");
                    Log.v("txtOfferName", txtOfferName);
                    Log.v("viewListAdapter.getItem(i)","" + viewListAdapter.getItem(i));
                    entitiesHashMap = (HashMap<String, String>) viewListAdapter.getItem(i);
                    hashMapListForListViewcopy.add(entitiesHashMap);
                }
            }
        }   
        viewListAdaptercopy.notifyDataSetChanged();
    }   

Post a Comment for "Android Listview Based On Simpleadapter Includes Image Descriptions When Searching Using Textwatcher"