java - TextView as attribute? -


i'd use textview attribute

private textview = (textview) findviewbyid(r.id.tv_up); private textview mid = (textview) findviewbyid(r.id.tv_mid); private textview down = (textview) findviewbyid(r.id.tv_down); 

instead of define evertime new:

public void onbuttonclickup(view v) {         textview = (textview) findviewbyid(r.id.tv_up);         textview mid = (textview) findviewbyid(r.id.tv_mid);         textview down = (textview) findviewbyid(r.id.tv_down);         <..> }  public void onbuttonclickdown(view v) {         textview = (textview) findviewbyid(r.id.tv_up);         textview mid = (textview) findviewbyid(r.id.tv_mid);         textview down = (textview) findviewbyid(r.id.tv_down);         <..> } 

the upper methode producing force close error on android device. how solve or possible?

thanks!

public class testactivity extends activity {      private textview up;     private textview mid;     private textview down;  @override public void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.main);       = (textview) findviewbyid(r.id.tv_up);      mid = (textview) findviewbyid(r.id.tv_mid);      down = (textview) findviewbyid(r.id.tv_down);  } 

i'm not sure why app crashing, save lot of headache declaring/assigning widgets this... 1 time whole activity.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -