如何解决ArrayAdapter 大小为 2,但 editText 为空
BusDatabase = new BusesDatabase(getActivity());
List<String> list = BusDatabase.getAllPlaces();
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(),android.R.layout.simple_list_item_1,list);
AutoCompleteTextView editText = (AutoCompleteTextView)view.findViewById(R.id.autoComplete);
editText.setAdapter(adapter);
解决方法
由于您正在处理片段,因此需要通过片段的膨胀的 rootView 来引用视图。所以:
View rootView = inflater.inflate(R.layout.fragment1,container,false);
EditText myEditText = rootView.findViewById(R.id.fragment_edit_text);
然后使用您的 myEditText
。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。