更新时间:2023-01-07 08:41:33
选项1:使用boolean accountsAdded=false;
,在需要时将其设置为true
Option #1: Use boolean accountsAdded=false;
, setting it to true
when needed
选项2:使用l.findViewById(R.id.accounts)
并查看是否返回null
Option #2: Use l.findViewById(R.id.accounts)
and see if that returns null
顺便说一句,如果R.layout.forms
的根窗口小部件不是R.id.accounts
View
,您将崩溃,因此请通过addView()
将view
而不是item
添加到l
.
BTW, you will crash if the root widget of R.layout.forms
is not the R.id.accounts
View
, so please add view
, not item
, to l
via addView()
.