First article
Private LinearLayout Generateheadofcontrol () {LinearLayout layouthead = createlayout (linearlayout.horizontal); Button Datebutton = Generatedatebutton (); Button Itembutton = Generateitembutton (); Datebutton.setlayoutparams (New Linearlayout.layoutparams ( LinearLayout.LayoutParams.WRAP_CONTENT)); Itembutton. Setlayoutparams (New Linearlayout.layoutparams ( LinearLayout.LayoutParams.WRAP_CONTENT)); Layouthead.addview (Datebutton); Layouthead.addview (Itembutton); return layouthead;} ========================== note in the LinearLayout to set the params with ViewGroup Layoutparams, will be wrong, the above code OK ~
Second article
Textview.setlayoutparams (New Textswitcher.layoutparams (
Layoutparams.fill_parent, layoutparams.fill_parent));
Why use Textswitcher's layoutparams? Check the API, you can see such a sentence these supply parameters to the parent of this view specifying how it should be arranged. This means that you must use the parent control's layoutparams. If the parent control is linearlayout, then of course it must be written linearlayout.layoutparams
Setlayoutparams method settings in Android programming