Null pointer Exception - findViewById()

后端 未结 10 2677
情歌与酒
情歌与酒 2020-11-21 04:16

Can anyone help me to find out what can be the issue with this program. In the onCreate() method the findViewById() returns null for all ids and th

10条回答
  •  有刺的猬
    2020-11-21 04:51

    In my case, it was a stupid mistake on my part. I had written code in the OnCreate method but it was above the setContentView line of code. Once I moved my code below this line the application started working fine.

    setContentView(R.layout.activity_main);
    

提交回复
热议问题