0
我是創建android應用程序的總新手。我可以在OnCreate方法中使用AXML中的對象,但是我不能在事件處理程序radioButton_Click中使用它們。我不想知道如何在事件處理程序radioButton_Click中使用它們。在OnCreate之外使用UI對象方法
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
RadioButton radioButton1 = FindViewById<RadioButton>(Resource.Id.radioButton1);
RadioButton radioButton2 = FindViewById<RadioButton>(Resource.Id.radioButton2);
radioButton1.Click += radioButton_Click;
radioButton2.Click += radioButton_Click;
//radioButton1 and radioButton2 are recognized here.
}
void radioButton_Click(object sender, EventArgs e)
{
//radioButton1 and radioButton2 are not recognized here.
//I want to know how to use IN THIS METHOD the objects loaded from the AXML
// in OnCreate (the two radio buttons)
}