forked from Clancey/MonoDroid.Dialog
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathButtonElement.cs
39 lines (35 loc) · 1005 Bytes
/
ButtonElement.cs
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System;
using Android.Content;
using Android.Views;
using Android.Widget;
namespace Android.Dialog
{
public class ButtonElement : StringElement, View.IOnClickListener
{
public ButtonElement(string caption, EventHandler tapped)
: base(caption, Resource.Layout.dialog_button)
{
Click = tapped;
}
public override View GetView(Context context, View convertView, ViewGroup parent)
{
Button button;
var view = DroidResources.LoadButtonLayout(context, convertView, parent, LayoutId, out button);
if (view != null)
{
button.Text = Caption;
button.SetOnClickListener(this);
}
return view;
}
public override string Summary()
{
return Caption;
}
public void OnClick(View v)
{
if (Click != null)
Click(this, EventArgs.Empty);
}
}
}