android - Cannot add View To the relative Layout -


i making activity takes int position activity class formula have formula, variables , title , want create activity taking formula , setting title , making edit text views variables user add values them , return result dialogue problem views add programitically not displayed, plz help

  public class displayfomula extends appcompatactivity {  @targetapi(build.version_codes.jelly_bean_mr1) @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_display_fomula);     db db = new db(this);     bundle = getintent().getextras();     int pos = extra.getint("id");     final formula form = db.getformula(pos);     relativelayout layout=new relativelayout(this);     textview tw1 =(textview) findviewbyid(r.id.textview11);     tw1.settext(form.title);      final string[] var = form.var;     int i=0;     final edittext[] ed = new edittext[50];     for(;i<var.length;i++){         relativelayout.layoutparams params = new relativelayout.layoutparams(viewgroup.layoutparams.match_parent,                 viewgroup.layoutparams.wrap_content);     ed[i]= new edittext(this);     ed[i].setid(i);         ed[i].sethint(var[i]);         ed[i].settextalignment(view.text_alignment_center);      ed[i].setlayoutparams(params);         if(i!=0) params.addrule(relativelayout.below,ed[i-1].getid());         else params.addrule(relativelayout.below,r.id.textview11);     layout.addview(ed[i],params);}     button btn = new button(this);     relativelayout.layoutparams params = new relativelayout.layoutparams(viewgroup.layoutparams.match_parent,             viewgroup.layoutparams.wrap_content);     btn.setid(i);     params.addrule(relativelayout.center_in_parent);     btn.setlayoutparams(params);     btn.settext("go!");     layout.addview(btn,params);     params = new relativelayout.layoutparams(viewgroup.layoutparams.match_parent,             viewgroup.layoutparams.match_parent);     addcontentview(layout,params);     btn.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             double[] varin=new double[var.length];             for(int =0;i<var.length;i++){                 double dbl = double.parsedouble(ed[i].gettext().tostring());                 varin[i]=dbl;             }             string res = string.valueof(form.result(varin));           }     });   } 

}

you adding views relativelayout layout. think u have'nt add layout view activity_display_fomula view. viewgroup activity_display_fomula , add relativelayout layout it..


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -