定义
Button button1 = FindViewById<Button>(Resource.Id.button1);
Button button2 = FindViewById<Button>(Resource.Id.button2);
Button button3 = FindViewById<Button>(Resource.Id.button3);
Button buttonOK = FindViewById<Button>(Resource.Id.buttonOK);
button1.Visibility = ViewStates.Visible;
button2.Visibility = ViewStates.Visible;
button3.Visibility = ViewStates.Visible;
button1.Text = ProductName[0].ToString();
button2.Text = ProductName[1].ToString();
button3.Text = ProductName[2].ToString();
我想使用以下
for (int i; i < length; i++)
{
button[i].Visibility = ViewStates.Visible;
button[i].Text = ProductName[0].ToString();
}
如何完成此
答案 0 :(得分:1)
定义按钮数组:
Button[] buttons = new Button[4];
buttons[0] = FindViewById<Button>(Resource.Id.button1);
buttons[1] = FindViewById<Button>(Resource.Id.button2);
buttons[2] = FindViewById<Button>(Resource.Id.button3);
buttons[3] = FindViewById<Button>(Resource.Id.buttonOK);