Tirolel
Tirolel

Reputation: 928

Textwatcher filtering list

I have a problem and it seems like its only me who has it. I have implemented textwatcher and when I filtering a string in listview it's showing the object twice in the list.

This what I'm doing

filterText = (EditText) findViewById(R.id.EditText01);
filterText.addTextChangedListener(filterTextWatcher);

and here is the adapter and textwatcher.

        adapter2 = new SimpleAdapter(ListBased.this, ListBasedList,
                R.layout.list_item,new String[] 
                       { TAG_Location_Name, TAG_Address, TAG_Dist, TAG_Postal, TAG_Location_id, TAG_City, TAG_Company_id, TAG_Lat, TAG_Lng}, new int[] {
                        R.id.location_name, R.id.location_adress, R.id.dist, R.id.postal, R.id.location_location_id, R.id.location_city, R.id.location_company_id, R.id.lat, R.id.lng});
                    setListAdapter(adapter2);
    }
}

private TextWatcher filterTextWatcher = new TextWatcher() 
{
    public void afterTextChanged(Editable s) {
         }
    public void beforeTextChanged(CharSequence s, int start, int count,
            int after) {
    }
    public void onTextChanged(CharSequence s, int start, int before,
            int count) {
        adapter2.getFilter().filter(s);
    }
};

its working fine like typed but here is a screenshot how it showing it.

Screenshot here!

Anyone can explain me the issue?

Upvotes: 0

Views: 1014

Answers (1)

donison24x7
donison24x7

Reputation: 304

I had the same problem. I figured it out. It is due to you have the same text "Sindal" in name and city fields of the list.

Upvotes: 1

Related Questions