【发布时间】:2016-09-30 09:35:51
【问题描述】:
我有带有总线信息列表的 ListView,我想在 Adapter 或 ListView 上应用多重过滤器,我已经在 ListView 上完成了实时搜索过滤器,
这是我的活动:
public class FilterListActivity extends Activity implements TextWatcher {
private static List<Country> countries = Storage.getItems();
private EditText editTextFilter;
private ListView listViewCountries;
private CountryListAdapter adapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
adapter = new CountryListAdapter(this, countries);
editTextFilter = (EditText)findViewById(R.id.editTextFilter);
editTextFilter.addTextChangedListener(this);
listViewCountries = (ListView)findViewById(R.id.listViewCountries);
listViewCountries.setAdapter(adapter);
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
adapter.getFilter().filter(s);
}
@Override
public void afterTextChanged(Editable s) {}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
}
当我在文本视图上搜索时,它的搜索非常好,但我也想用区域和人口过滤 ListView。
【问题讨论】:
-
你需要做更多的研究......尝试一些东西,编写一些代码......然后如果你的代码有问题,最终回到这里......因为现在你的问题是:免费为我写 xxx 之类的应用
-
对不起 Selvin,我被问到了错误的问题,这种方法我在国家搜索中遵循了这种工作正常,但我想为区域过滤器和人口过滤器实现相同的功能
标签: android listview adaptor listview-filter