How to get text from AutoCompleteTextView?

前端 未结 9 1754
青春惊慌失措
青春惊慌失措 2020-12-05 04:25

I have an AutoCompleteTextView in my app which works. I have successfully created an onClickItemListener. The question is how to grab the text the

9条回答
  •  长情又很酷
    2020-12-05 04:57

    Here is the code that will solve the problem.

     private AdapterView.OnItemClickListener onItemClickListener = new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView parent, View view, int pos, long id) {
            int index = (int) view.getTag();
            Object item = parent.getItemAtPosition(index);
            if (item instanceof SearchItemShareConnectionDAO) {
                SearchItemShareConnectionDAO dao = (SearchItemShareConnectionDAO) item;
    
            }
        }
    };
    

    SetTag(Dao.getPosition) in getView() method of adapter.

提交回复
热议问题