search

Home  >  Q&A  >  body text

android - 一个不太理解的问题,继承BaseAdapter在getView方法中获取一个布局的实例,却为空指针

代码文件:

布局文件:

真是被搞@_@了

ViewHolder类:

怪我咯怪我咯2772 days ago643

reply all(3)I'll reply

  • 高洛峰

    高洛峰2017-04-17 17:00:11

    Your statement block should not be empty, so a null pointer error will be reported. moduels.tradeModelLabel,而是setText中的内容。
    如果moduels.tradeModelLabel为空,上面的if-else

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 17:00:11

    If this kind of inexplicable problem occurs, clean or rebuild the project first. Sometimes android studio will miss some codes when compiling..

    reply
    0
  • 阿神

    阿神2017-04-17 17:00:11

    Change your first judgment to tradeModelString == null If tradeModelString is null
    This sentence will report a null pointer

    reply
    0
  • Cancelreply