-
Notifications
You must be signed in to change notification settings - Fork 0
/
AddActivity.cs
68 lines (64 loc) · 2.4 KB
/
AddActivity.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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Support.V7.App;
using Android.Views;
using Android.Widget;
namespace HangingMan
{
[Activity(Label = "AddActivity")]
public class AddActivity : AppCompatActivity
{
EditText cat, wor;
Button sav;
protected override void OnCreate(Bundle savedInstanceState)
{
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
SetContentView(Resource.Layout.Add);
base.OnCreate(savedInstanceState);
Words.InitDb();
sav = FindViewById<Button>(Resource.Id.save);
cat = FindViewById<EditText>(Resource.Id.category);
wor = FindViewById<EditText>(Resource.Id.word);
sav.Click += OnClick;
}
private void OnClick(object sender, EventArgs e)
{
Button btn = (Button)sender;
if (btn == sav)
{
Words.Add(new Word(cat.Text, wor.Text, wor.Text.Length));
Toast.MakeText(this, "המילה הוספה בהצלחה ", ToastLength.Long).Show();
}
}
public override bool OnCreateOptionsMenu(Android.Views.IMenu menu)//יצירת תפריט
{
base.MenuInflater.Inflate(Resource.Menu.menu1, menu);
return true;
}
public override bool OnOptionsItemSelected(Android.Views.IMenuItem item)//מה יקרה כאשר נלחץ על אחד הדברים בתפריט
{
if (item.ItemId == Resource.Id.add)
{
return true;
}
else if (item.ItemId == Resource.Id.home)
{
Intent x = new Intent(this, typeof(HomeActivity));
StartActivity(x);
return true;
}
return base.OnOptionsItemSelected(item);
}
public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Android.Content.PM.Permission[] grantResults)
{
Xamarin.Essentials.Platform.OnRequestPermissionsResult(requestCode, permissions, grantResults);
base.OnRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
}