java - Android: Why can I not setText in the same line as findViewById -
i not sure if android issue or androidstudio issue. why valid:
textview currentitem currentitem = (textview)findviewbyid(r.id.mytext); currentitem.settext("text");
but not (cannot resolve method settext(java.lang.string))
(textview)findviewbyid(r.id.mytext).settext("text");
not big deal, have code requires lot of text updates. cleaner if in 1 line.
findviewbyid
returns generic 'view
', hence have cast textview
before can set text. in piece of code trying invoke settext on 'view' object rather 'textview' object.
try :
((textview)findviewbyid(r.id.mytext)).settext("text");
Comments
Post a Comment