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

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

matplotlib support failed in PyCharm on OSX -

python - Matplotlib: TypeError: 'AxesSubplot' object is not callable -