我有一个自定义的的ListView
有两个 TexView
,我填补它与此code一SimpleAdapter以下
I have a custom ListView
with two TexView
, I fill it with a SimpleAdapter with this code below
adapter = new SimpleAdapter(this, list,
R.layout.activity_lista_vehiculo,
new String[] { "value1","value2" },
new int[] {R.id.line_a, R.id.line_b});
setListAdapter( adapter );
我怎么可以把一个过滤器,它从的EditText
或搜索查看
?
SimpleAdapter
有一个内置的 SimpleFilter
该过滤器的的ListView适配器
的有preFIX内容。如果这是你想要的,你可以使用下面的code做过滤工作:
SimpleAdapter
has a build-in SimpleFilter
which filters the content of your ListView adapter
with a prefix. If this is what you want, you can use the following code to do the filter work:
yourEditText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
// When user changed the Text
yourSimpleAdapter.getFilter().filter(cs);
}
@Override
public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
int arg3) {
}
@Override
public void afterTextChanged(Editable arg0) {
}
});