Android — AutocompleteTextView dropdown question

删除回忆录丶 提交于 2019-12-12 05:57:01

问题


So here's my issue.

String[] list = ws.getList() ///returns a String[] of 2900 elements.

AutoCompleteTextView actv= (AutoCompleteTextView)findViewById(R.id.field);

ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, R.layout.dropdownmenu, list); 
actv.setAdapter(adapter);

My question is... when I run my application, my autocompletetextview does not generate any sort of text whenever I type in it. However, if I shorten my list to like, 30 elements, it works perfectly. Are autocompletetextviews limited to a certain amount of items?

Thanks!


回答1:


I have an autocompletetextview in an app i'm developping that has about 5000 entries and it works fine. However, it is significantly slow on a real device without debugging set to true. So if you run it in the emulator it is very likely that you are not seeing anything as it would take a long long type to perform filtering and then display the suggestions.

To my knowledge, there is no limit on the numbers of item




回答2:


I'm having the same issue. I've been running a lot of tests to try slim down the problem.

I'm using an xml file to supply the array to my autocomplete field. In 2.2 the activity crashes when the array is too large. In 2.3 the same array doesn't cause any issues at all.

My array consists of around 950 nodes. Once I slim it doen to about 200 it's fine. (I didn't note the exact number that causes a crash.)




回答3:


I had a similar issue but some of my Strings were null or empty, because the data was pulled from an unfamiliar database. I created my list like this and it works just fine. The empty or null strings in the list prevent the dropdown from opening.

if(mystring!=null && !mystring.isEmpty()) { //add to list here }

Maybe your test of 30 is working because you know each string has a value. I did a similar test and found that it worked, which led me to the solution/idea above... two years later... I wonder if he's still stuck on this problem ;)



来源:https://stackoverflow.com/questions/4833245/android-autocompletetextview-dropdown-question

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!