Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Android.OS;
- using Android.App;
- using Android.Graphics;
- using Android.Widget;
- using System;
- namespace p1
- {
- [ActivityAttribute(Label = "p1", MainLauncher = true)]
- public class Class1 : Activity
- {
- EditText dag, maand, jaar;
- TextView tekst2, oud;
- Button knop;
- int day, month, year;
- string dagen;
- protected override void OnCreate(Bundle b)
- {
- base.OnCreate(b);
- LinearLayout layout;
- layout = new LinearLayout(this);
- layout.Orientation = Orientation.Vertical;
- TextView tekst1;
- tekst1 = new TextView(this);
- tekst1.Text = "schrijf hier uw geboortedatum op in de vorm dd/mm/jjjj";
- tekst2 = new TextView(this);
- oud = new TextView(this);
- knop = new Button(this);
- knop.Text = "klik hier";
- knop.Click += klik;
- dag = new EditText(this);
- dag.TextChanged += invoer1;
- maand = new EditText(this);
- maand.TextChanged += invoer1;
- jaar = new EditText(this);
- jaar.TextChanged += invoer1;
- layout.AddView(tekst1);
- layout.AddView(dag);
- layout.AddView(maand);
- layout.AddView(jaar);
- layout.AddView(knop);
- layout.AddView(tekst2);
- layout.AddView(oud);
- this.SetContentView(layout);
- }
- private void klik(object sender, EventArgs e)
- {
- DateTime birthday = new DateTime(year, month, day);
- TimeSpan days = DateTime.Now - birthday;
- dagen = days.ToString();
- oud.Text = "U bent " + dagen + "dagen oud.";
- }
- public void invoer1(object o, Android.Text.TextChangedEventArgs e)
- {
- Console.WriteLine(dag.Text);
- string dag1 = dag.Text;
- string maand1 = maand.Text;
- string jaar1 = jaar.Text;
- day = int.Parse(dag1);
- month = int.Parse(maand1);
- year = int.Parse(jaar1);
- tekst2.Text = "U bent geboren op: " + day + "-" + month + "-" + year;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement