在我的程序中,有超过 2000 个以编程方式创建的按钮。它们看起来像这样:
//Parameters of buttons
LinearLayout.LayoutParams lParams = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT);
//Create a button based on...
if (bla-bla)
{
Button ammian_martsellin_1=new Button(this); ammian_martsellin_1.setText(R.string.ammian_martsellin_1); llPreViewList.addView(ammian_martsellin_1, lParams);
Button ammian_martsellin_2=new Button(this); ammian_martsellin_2.setText(R.string.ammian_martsellin_2); llPreViewList.addView(ammian_martsellin_2, lParams);
}
//And a lot of these groups of buttons.
如何为这些按钮添加额外的参数,例如“lParams”之类的重力和文本大小?