NullPointerException on Button.findViewById()

NullPointerException on Button.findViewById(),第1张

NullPointerException on Button.findViewById()

findViewById()
以错误的方式调用该方法。应该在
Activity
本身而不是引用上调用它
Button
。更换

b1=(Button) b1.findViewById(R.id.button);

b1=(Button) findViewById(R.id.button);

此时的

b1
引用为null,这是的原因
NullPointerException



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5177845.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-18
下一篇 2022-11-18

发表评论

登录后才能评论

评论列表(0条)

保存