android - Graphical Layout Editor instantiating custom view but when ran and adding my own custom view via Java, nothing shows -


so when add custom view, layer (look below class), relative layout doesn't show up

i have method change layer

public void setcurrentlayer(int currentlayer) {     this.currentlayer = currentlayer;     this.removeallviews();     addview(getlayer(currentlayer)); } 

layer class:

public layer(context context, attributeset atrbset) {     super(context, atrbset);     setbackgroundcolor(color.cyan);     this.atrbset = atrbset;     leveltiles = new tile[width][height];  }  public void generatelayer(int layernumber) {     if (layernumber == 0) {         (int y = 0; y < height; y++)             (int x = 0; x < width; x++) {                 leveltiles[x][y] = new grass(this.getcontext(), atrbset);                 addtiletolayer(new grass(this.getcontext(), atrbset));             }     } else {         (int y = 0; y < height; y++)             (int x = 0; x < width; x++) {                 leveltiles[x][y] = new stone(this.getcontext(), atrbset);                 addtiletolayer(new stone(this.getcontext(), atrbset));             }     } } private void addtiletolayer(tile tile) {     addview(tile, params); } 

this works perfect inside graphical editor. nothing doesn't work. however, when create new layer in java (i.e. new layer(context, attributeset)), shows blank. i'd same thing tiles, don't chance show because layer isn't showing up.

so question is:

why happening , how can fix it?

if there code guys think may have left out, add if ask.

progress update 1: i've set log prints, , each layer reaching point it's created , added

progress update 2: i've set if(layer == null) statements throw runtime exceptions if are, no errors when ran.

i fixed issue avoiding adding things inside class extending view, , instead moving main class.


Popular posts from this blog