java - Can't acces TextView defined in onCreate -


this question has answer here:

i still java beginner , have problem have onclick function , of course oncreate in define textview value. when want edit textview onclick can't that. know how can make textview value "global".

final textview result = (textview) findviewbyid(r.id.result); 

you have instantiate textview after setcontentview() method :

public class mainactivity extends activity {  textview textview;  @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);     textview = (textview)findviewbyid(r.id.textview); }  } 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -