Home > Back-end >  Android studio dynamically add LinearLayout layout does not display, for help
Android studio dynamically add LinearLayout layout does not display, for help

Time:10-07

There is something wrong with the novice for help, the following code?
MLinearLayout=the findViewById (R.i d.m _linearlayout);
Final LinearLayout [] LinearLayout=new LinearLayout [10].
for(int i=0; i<10; I++) {
LinearLayout [I]=new linearLayout (this);
LinearLayout [I] setOrientation (HORIZONTAL);
LinearLayout [I] setHorizontalGravity (CENTER);
MLinearLayout. AddView (linearLayout [I]);
}

CodePudding user response:

Fumbling along while, turned out to be less container mLinearLayout attribute is set, the following Settings, solved,
MLinearLayout. SetOrientation (VERTICAL);
MLinearLayout. SetHorizontalGravity (CENTER);
  • Related