0
如何編輯通過下面顯示的代碼創建的按鈕?例如,我想將按鈕i = 4的文本從「test4」更改爲「changed4」。我該怎麼做?如何編輯由此代碼創建的按鈕?
containerLayout = (LinearLayout) findViewById(R.id.containerLayout);
for (int i = 0; i < 6; i++) {
Button button = new Button(this);
button.setBackgroundResource(R.drawable.button);
button.setTextAppearance(this, R.style.ButtonFontStyle);
button.setTextColor(getResources().getColor(R.color.white));
button.setTypeface(Typeface.DEFAULT_BOLD);
button.setId(i);
button.setText("test"+i);
containerLayout.addView(button);
}
謝謝你,我需要第二個。 –