2011-11-16 5 views
6

나는 어댑터를 가지고 있는데, 나는 listView를 필터하기 위해 ad.getFilter().filter(s);을 사용한다.
EditText에서 한 단어를 쓰면 잘 작동합니다.
단어 뒤에 공백 문자를 쓰면 작동하지 않습니다 (결과 행 없음).
예를 들어 name과 surmane으로 필터를 만들고 싶습니다. "Mario Rossi"을 edittext에 삽입하고 결과를 얻고 싶습니다. 내가 설명하기를 바랍니다.
고마워요.android에 대한 ListView 필터

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) { 
     ad.getFilter().filter(s);    
    } 

}; 
+0

몇 가지 작은 실수가이 게시물을 참조 http://stackoverflow.com/questions/9407428/filter-for-android-listview-space -캐릭터 –

답변

0

코드는 완벽하지만,이

private TextWatcher filterTextWatcher = new TextWatcher() { 

     public void afterTextChanged(Editable s) { 
       ad.getFilter().filter(s); 
     } 

     public void beforeTextChanged(CharSequence s, int start, int count, 
       int after) { 
     } 

     public void onTextChanged(CharSequence s, int start, int before, 
       int count) { 


     } 

    }; 
관련 문제