2013-07-11 4 views
0

나는 문제가 있으며 그걸 가지고있는 유일한 사람처럼 보입니다. textwatcher를 구현했으며 listview에서 문자열을 필터링하면 목록에 객체가 두 번 표시됩니다.텍스트 워처 필터링 목록

여기

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

을하고있는 무슨이 어댑터와 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); 
    } 
}; 

잘 작동하는 것처럼 작동하지만 여기에는 스크린 샷이 있습니다.

스크린 샷here!

누구든지 내게 문제를 설명 할 수 있습니까?

답변

1

같은 문제가있었습니다. 나는 그것을 알아. 이름과 도시 필드에 "Sindal"이라는 텍스트가 있기 때문입니다.

+0

사실입니다. 왜 이런 식 이었는지 알아내는 데는 시간이 걸렸습니다. 하지만 문제를 해결하는 데 도움이되는 어댑터를 만들었습니다. – Tirolel

+0

어느 어댑터입니까? 코드를 공유 할 수 있습니까? 감사합니다. – donison24x7

+0

내일 찾아서 대답으로 게시하려고합니다. – Tirolel