Null pointer Exception - findViewById()

后端 未结 10 2687
情歌与酒
情歌与酒 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:48

    What @Warlock said above is right , you should initial LinearLayout layout1, layout2, layout3 by the right way:

    LinearLayout layout1 = (LinearLayout) View.inflate(this, R.layout.first_View, null);
    LinearLayout layout2 = (LinearLayout) View.inflate(this, R.layout.second_View, null);
    LinearLayout layout3 = (LinearLayout) View.inflate(this, R.layout.third, null);
    

    wish my advise help you

提交回复
热议问题