在我的程序中有超過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」?
但我有很多的按鈕,我將不得不所有的按鈕來追加新的參數? – user2531700