我想在edittext中搜索联系人。但是edittext不显示联系人列表,请告诉我如何匹配电话号码以进行edittext搜索和显示。
String products[]={};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
mInflater = inflater;
View view = inflater.inflate(R.layout.contacts_list, container, false);
contactsList = (ListView) view.findViewById(R.id.contactsList);
inputSearch=(EditText) view.findViewById(R.id.inputSearch);
adapter = new ArrayAdapter<String>(getActivity(), R.layout.listitem, R.id.product_name, products);
contactsList.setAdapter(adapter);
(this,android.R.layout.select_dialog_item,str));
inputSearch.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence cs, int arg1, int arg2, int arg3)
{
ContactsFragment.this.adapter.getFilter().filter(cs);
}
}
}
});
return view;
}