3
我有一個ArrayList,其中有60-70個元素。我如下所示將一個適配器設置爲AutoCompleteTextView。AutoCompleteTextView不顯示下拉框,出現警告
AutoCompleteTextView mRecipient = (AutoCompleteTextView) this.findViewById(R.id.recipient);
mRecipient.setThreshold(1);
Log.i("Array list", ""+names);// Here I got the arrayList
ArrayAdapter<String> nameadapter=new ArrayAdapter<String>(MyClass.this, android.R.layout.simple_list_item_1, names);
mRecipient.setAdapter(nameadapter);
但下拉列表顯示不出來,我在logcat中得到了一些警告(不errror)。
04-21 17:15:53.017: W/Filter(15093): An exception occured during performFiltering()!
04-21 17:15:53.017: W/Filter(15093): java.lang.NullPointerException
04-21 17:15:53.017: W/Filter(15093): at android.widget.ArrayAdapter$ArrayFilter.performFiltering(ArrayAdapter.java:437)
04-21 17:15:53.017: W/Filter(15093): at android.widget.Filter$RequestHandler.handleMessage(Filter.java:234)
04-21 17:15:53.017: W/Filter(15093): at android.os.Handler.dispatchMessage(Handler.java:99)
04-21 17:15:53.017: W/Filter(15093): at android.os.Looper.loop(Looper.java:123)
04-21 17:15:53.017: W/Filter(15093): at android.os.HandlerThread.run(HandlerThread.java:60)
此外,我有一個ListView下面這個,現在是空的。
有人可以弄清楚這個警告的含義嗎?
確保'names'不爲空 –
實際上,請確保'names'中的項目都不爲'null'。 – Vikram
'names'不爲null,但列表中有空項目。這是問題嗎? – Nizam