summaryrefslogtreecommitdiff
path: root/Xamarin.Forms.Platform.Android/Cells/SwitchCellView.cs
blob: f15c41b0c2c520f075457e50dc5f7337cc6038ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
using Android.Content;
using Android.Widget;

namespace Xamarin.Forms.Platform.Android
{
	public class SwitchCellView : BaseCellView, CompoundButton.IOnCheckedChangeListener
	{
		public SwitchCellView(Context context, Cell cell) : base(context, cell)
		{
			var sw = new global::Android.Widget.Switch(context);
			sw.SetOnCheckedChangeListener(this);

			SetAccessoryView(sw);

			SetImageVisible(false);
		}

		public SwitchCell Cell { get; set; }

		public void OnCheckedChanged(CompoundButton buttonView, bool isChecked)
		{
			Cell.On = isChecked;
		}
	}
}