0

先生,我们如何将 autocompletext 联系人与 android.contact 中的 listview 联系人匹配从 phone.contact 中选择所有联系人。请告诉我如何同时匹配联系人搜索 autcomplete 和 listviw。

String products[]= { contactsList.};
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
Bundle savedInstanceState) {


     contactsList = (ListView) view.findViewById(R.id.contactsList);
    contactsList.setOnItemClickListener(this);
    contactsList.setTextFilterEnabled(true);

     inputSearch=(AutoCompleteTextView) view.findViewById(R.id.inputSearch);
      contactsList.setAdapter(new ArrayAdapter<String>(getActivity(),
             android.R.layout.simple_list_item_1,products ));
     inputSearch.setThreshold(1);
     inputSearch.setAdapter(adapter);
     inputSearch.setOnClickListener(new OnClickListener() {

    @Override
        public void onClick(View v) {
        }
    });
      inputSearch.setOnItemClickListener(new OnItemClickListener() {

        @Override
    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                long arg3) {
Map<String, String> map = (Map<String, String>)arg0.getItemAtPosition(arg2);
    String name  = map.get("Name");
    String number = map.get("Phone");
   inputSearch.setText(""+name+"<"+number+">"); 


        }
    })  ;`




    return view;
4

1 回答 1

0

试试这个模式搜索..

        for(int i = 0; i < product.length; i++) {

                   String str = product[i].toLowerCase();
                   //key is the itemclicked list element  
                   Pattern p = Pattern.compile(key, Pattern.CASE_INSENSITIVE);
                   Matcher m = p.matcher(str);
                    if (m.find()){
                               //Do your stuff.
                                }            
                        }
于 2013-10-24T12:32:44.700 回答