开发者

java.lang.NullPointerException - AutoCompleteTextView - HoneyComb

I am getting a weird issue when using AutoCompleteTextView component on a device running on Honeycomb (Android 3.0) (using Motorola Xoom to test). I get a Nullpointer exception with the following stacktrace :

FATAL EXCEPTION: main java.lang.NullPointerException at android.widget.PopupWindow.getMaxAvailableHeight(PopupWindow.java:1152) at android.widget.ListPopupWindow.buildDropDown(ListPopupWindow.java:1054) at android.widget.ListPopupWindow.show(ListPopupWindow.java:516) at android.widget.AutoCompleteTextView.showDropDown(AutoCompleteTextView.java:1047) at android.widget.AutoCompleteTextView.updateDropDownForFilter(AutoCompleteTextView.java:931) at android.widget.AutoCompleteTextView.onFilterComplete(AutoCompleteTextView.java:914) at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:285) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:126) at android.app.ActivityThread.main(ActivityThread.java:3997) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:491) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) at dalvik.system.NativeStart.main(Native Method)

Note that I do not get this exception on any other versions of Android including Ginger开发者_开发技巧bread. Its really hard to debug since I do not have the original source code of Honeycomb code base. I would appreciate if anyone can help me out.

Thanks, Torri.


I had the exact exception. Everything works in 2.*, but in 3.x there all thrown this exception, and simply try catch didn't work.

Finally I found that, if I remove the below line from the view, then it worked for me:

android:dropDownAnchor="@+id/searchField"


I am not sure if this can help but I had a similarly weird problem with a button. It worked fine on all versions except 3.0 So I did this:

try{
  mButton.setOnClickListener(...
     //code...

}catch(NullPointerException e){

}

After this no more errors and guess what? The button works fine now on 3.0 !

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜