Weird NullPointerException in Spinner

后端 未结 3 1641
长发绾君心
长发绾君心 2020-12-18 20:07

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:

         


        
相关标签:
3条回答
  • 2020-12-18 20:37

    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

    0 讨论(0)
  • 2020-12-18 20:53

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

    0 讨论(0)
  • 2020-12-18 20:57

    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

    0 讨论(0)
提交回复
热议问题