android - Do you check if inflated view is null or not? -
here simple method:
private void setupui(context context) { view view = layoutinflater.from(context).inflate(r.layout.layout_section_view, this); header = (textview) view.findviewbyid(r.id.layout_section_header); listview = (listview) view.findviewbyid(r.id.layout_section_listview); } lint advising check view null or not. guys check such conditions? if null because deleted layout xml, can check , throw nullpointerexception thrown anyway... what's point?
do check if inflated view null or not?
no, don't. if null can't handle during run-time, prefer instant error , fix (probably it's wrong filename or easy).
do guys check such conditions?
depends on condition... yes, lint has ideas.
so what's point?
to read more warning, press ctrl + 1 on lint warning , select explain issue...
if want rid of warning, can use @suppresslint annotation.
in earlier versions of lint warning didn't exist.
Comments
Post a Comment