Android-Change Layout of view dynamically -
i have view in activity :
for(int i=0;i<my_newsgroup.size();i++) { view my_updateview=new view(mainactivity.this); my_updateview =layoutinflater.from(mainactivity.this).inflate(r.layout.row2, null); ..... }
now want change layout of view dynamically !
how can ?
tnx ---------------------------------edit-------------------
linearlayout ll2 = (linearlayout)findviewbyid(r.id.parent2); for(int i=0;i<my_newsgroup.size();i++) { view my_updateview=new view(mainactivity.this); my_updateview = layoutinflater.from(mainactivity.this).inflate(r.layout.row2, null); .... ..... relativelayout.layoutparams relativeparams = new relativelayout.layoutparams(layoutparams.fill_parent, layoutparams.fill_parent); ll2.addview(my_updateview,relativeparams); myviewlist.add(my_updateview); }
myviewlist : list myviewlist=new arraylist();
and ! example if want hide view :
myviewlist.get(pos).setvisibility(view.gone);
but want change layout view !
you can't change view , reinflate different xml layout. can change view's container content. remove old view viewgroup , replace new one. here trivial example:
framelayout somelayout... somelayout.removeview(viewyouwanttoreplace); somelayout.addview(inflator.inflate(r.layout.row2, somelayout, false));
Comments
Post a Comment