【发布时间】:2014-10-10 08:40:36
【问题描述】:
在我的 android 应用程序中,我有一个数组列表,其中包含从服务器接收到的服务器数据。我需要在 arrayadapter 中使用这个 arraylist,以便在自动完成文本视图中使用它,以便在用户键入字符时显示建议。我已经看到很多教程在 arrayadapter 中使用字符串数组并将其设置为自动完成文本视图。但是还没有找到任何使用arraylist的解决方案。请帮帮我..
编辑:
这是我使用的代码:
View rootView = inflater.inflate(R.layout.fragment_community, container, false);
actv1=(AutoCompleteTextView)rootView.findViewById(R.id.autoCompleteTextView1);
actv2=(AutoCompleteTextView)rootView.findViewById(R.id.autoCompleteTextView2);
loc=new ArrayList<String>();
SplashScreen ss = new SplashScreen();
loc=ss.loc;
ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,loc);
添加 loc 在 logcat 中显示错误,如下所示:构造函数 ArrayAdapter(CommunityFragment, int, ArrayList) is undefined
【问题讨论】:
-
显示您尝试完成但不起作用的代码。是什么导致了问题?
-
查看我的编辑@ChiefTwoPencils。
-
将
ArrayAdapter<String>更改为ArrayAdapter<ArrayList<String>> -
@mmlooloo。它在 Eclipse 中显示如下错误:构造函数 ArrayAdapter
>(CommunityFragment, int, ArrayList ) is undefined -
@Tee Jay 删除我的建议并使用你的旧
标签: android arrays arraylist autocompletetextview