Skip to content Skip to sidebar Skip to footer

Weird Nullpointerexception In Spinner

Since Android 4.4 KitKat, i have weird crashes in my applications. It seems that it has something to do with spinner. This stacktrace of bug i am receiving: java.lang.NullPointerEx

Solution 1:

As Peterdk describe here . You dont need to remove

android:ellipsize="marquee"

He suggests using:

inflater.inflate(android.R.layout.simple_spinner_item, null);//WRONG inflater.inflate(android.R.layout.simple_spinner_item, parent, false);//GOOD

That fixed my issue. I guess Android 4.4 is trying to be strict about inflating layout

Solution 2:

So i check that line in TextView class in makeNewLayout method and found that this exception is happening on this line final int height = mLayoutParams.height; Layout params are probably null.. and this line is in block that handle ellipsizing long text .. so i removed that textView attribute in xml android:ellipsize="marquee" and then problem really disappears .. strange strange

Solution 3:

Thanks. I got away with the crash by removing android:ellipsize from all of my layouts.

Post a Comment for "Weird Nullpointerexception In Spinner"