可过滤的ArrayList基础适配器

时间:2016-05-03 21:20:02

标签: java android baseadapter android-filterable

我正在尝试创建一个可过滤的列表视图。列表视图的基本适配器与我发现的可过滤的任何内容不同,我无法弄清楚如何修改它以使其能够被过滤。适配器:

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    // Get the list view and set it up.
    ListView listView = (ListView)     view.findViewById(com.yanay.yanay.apps.odds.R.id.ping_list);
    listView.setOnItemClickListener(mOnItemClickListener);
    listView.setEmptyView(view.findViewById(android.R.id.empty));
    if (listView.getAdapter() == null) {
        mPingerAdapter = new PingerAdapter(getActivity());
        listView.setAdapter(mPingerAdapter);

        inputSearch = (EditText) view.findViewById(R.id.inputSearch);
        inputSearch.addTextChangedListener(new TextWatcher() {

            @Override
            public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3) {
                // When user changed the Text
                FriendlyPingFragment.this.mPingerAdapter.getFilter().filter(cs);
            }

            @Override
            public void beforeTextChanged(CharSequence arg0, int arg1, int arg2,
                                          int arg3) {
                // TODO Auto-generated method stub

            }

            @Override
            public void afterTextChanged(Editable arg0) {
                // TODO Auto-generated method stub
            }
        });

        }

创建列表视图的片段部分:

{
...
   firstView:{
     marginTop : PixelRatio.getPixelSizeForLayoutSize(10)
   }
...
}

目前无法解析getFilter()。谢谢你的帮助

0 个答案:

没有答案