You need to be careful when defining the xml elements of layout.
In the layout, mostly I specified the id by "android:id".
When I used "id" mistakenly, "findViewByI()" cannot find the view (e.g., a button) in the OnClickListener's "onClick()" definition (it returned null)!
本文讨论了在定义XML布局文件中的元素ID时应注意的问题。作者提到,在定义ID时使用android:id而非id的重要性,因为错误地使用id可能导致在OnClickListener中通过findViewByI()找不到对应的视图(如按钮),返回null。

被折叠的 条评论
为什么被折叠?



