Skip to content
This repository has been archived by the owner on Feb 8, 2019. It is now read-only.

HelloMonoReactiveAndroid

atsushieno edited this page Feb 12, 2012 · 3 revisions
using System;

using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
using System.Reactive;
using System.Reactive.Linq;

namespace MonoAndroidApplication2
{
    [Activity(Label = "MonoAndroidApplication2", MainLauncher = true, Icon = "@drawable/icon")]
    public class Activity1 : Activity
    {
        int count = 1;

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById<Button>(Resource.Id.MyButton);
            Observable.FromEventPattern(button, "Click")
                .Subscribe (v => button.Text = String.Format ("{0} clicks!", count++));
        }
    }
}
Clone this wiki locally