java - removeview() doesn't remove android -
i have layout (main) when click on button shows relativelayout (newlayout) textview , edittext. when want leave relativelayout (clicking on button), doesn´t dissappear. code this:
when click on button, code:
public boolean onoptionsitemselected(menuitem item) { switch (item.getitemid()) { case r.id.action_hide: relativelayout main = (relativelayout) findviewbyid(r.id.atraccion_layout); relativelayout newlayout= (relativelayout) view.inflate(this, r.layout.newlayout, null); main.addview(newlayout); default: return super.onoptionsitemselected(item); } }
then when click on button, code is:
public void close(view v){ relativelayout main = (relativelayout) findviewbyid(r.id.atraccion_layout); relativelayout newlayout = (relativelayout) view.inflate(this, r.layout.newlayout, null); main.removeview(comentarlayout); main.forcelayout(); }
but newlayout still there.
tried also:
((relativelayout)v.getparent()).removeview(v); main.removeview((view)v.getparent()); newlayout.setvisibility(v.invisible); newlayout.setvisibility(v.gone); ((relativelayout)newlayout.getparent()).forcelayout(); ((relativelayout)newlayout.getparent()).removeview(comentarlayout);
without success.
can me why isnt removing layout?
i resolved defining class atributes whith layers
public class activityclass extends activity{ private relativelayout main; private relativelayout newlayout; protected void oncreate(bundle b){...} ... public boolean onoptionsitemselected(menuitem item) { switch (item.getitemid()) { case r.id.action_hide: main = (relativelayout) findviewbyid(r.id.atraccion_layout); newlayout= (relativelayout) view.inflate(this, r.layout.newlayout, null); main.addview(newlayout); return true; } default: return super.onoptionsitemselected(item); } public void close(view v){ main.removeview(newlayout); main.forcelayout(); } }
Comments
Post a Comment