findViewById() returns null for custom component in layout XML, not for other components

前端 未结 18 1531
情歌与酒
情歌与酒 2020-11-28 10:36

I have a res/layout/main.xml including these elements and others:



        
18条回答
  •  感动是毒
    2020-11-28 11:33

    The findViewById() method sometimes returns null when the root of layout has no android:id attribute. Eclipse wizard for generating layout xml file does not automatically generate android:id attribute for the root element.

提交回复
热议问题