2017-06-02 156 views
0

有谁知道如何设置开关位置的代码?例如,当我按下一个按钮时,我想将所有开关都设置为关闭状态......无法弄清楚。Xamarin Android设置开关位置

+0

使用'检查切换属性(android中的开关称为切换)按钮。例如'view.FindViewById (Resource.Id.toggleButton).Checked = false'。 – Jack

回答

0

您可以通过id属性在axml访问交换机(机器人:ID = “@ + ID /交换机1” 为例),然后设置经过属性:

Button button = FindViewById<Button>(Resource.Id.myButton); 

Switch switchControl = FindViewById<Switch>(Resource.Id.switch1); 

button.Click += delegate { 
    switchControl.Checked = true; // or false 
};