0

私には問題があり、それを抱えているのは私だけのようです。textwatcher を実装しました。リストビューで文字列をフィルタリングすると、オブジェクトがリストに 2 回表示されます。

これは私がやっていることです

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

ここにアダプターとテキストウォッチャーがあります。

        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);
    }
};

入力したように正常に動作しますが、これがどのように表示されるかを示すスクリーンショットです。

スクリーンショット はこちら

誰でも私に問題を説明できますか?

4

1 に答える 1

1

私も同じ問題を抱えていました。私はそれを考え出した。これは、リストの名前と都市のフィールドに同じテキスト「Sindal」があるためです。

于 2014-04-01T07:18:09.937 に答える