2011-10-11 3 views
5
ArrayAdapter<String> adapter1 = new ArrayAdapter<String>(Application.getContext(), R.layout.report_add_list_item, ListUtil.asStringList(ContactServiceUtil.getContacts())); 
    multiAutoCompleteContacts = (MultiAutoCompleteTextView) findViewById(R.id.multiAutoCompleteGuests); 
    multiAutoCompleteContacts.setAdapter(adapter1); 
    multiAutoCompleteContacts.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer()); 
    multiAutoCompleteContacts.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { 

     public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) { 
      System.out.println("click"); 
     } 

     public void onNothingSelected(AdapterView<?> adapterView) { 
      return; 
     } 
    }); 

나는 onItemSelected 안에 들어 가지 않습니다. ID를 얻기 위해 내 목록 중 어느 것을 선택해야합니까?MultiAutoCompleteTextView가 작동하지 않습니다. OnItemSelectedListener

답변

2

OnItemSelectedListener는 AutoCompleteTextView (또는 MultiAutoCompleteTextView)에 의해 트리거되지 않습니다. 대신 OnItemClickListener 사용 :

setOnItemClickListener(new AdapterView.OnItemClickListener() { 
    @Override 
    public void onItemClick(AdapterView<?> parent, View view, int position, long id) { 
     Object item = parent.getItemAtPosition(position); 
    } 
});