Beispiel #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.
            Button.AccessibilityIdentifier = "myButton";

            Button.TouchUpInside += async delegate {
                XamarinWorkshopLab2.MyClass myClass = new XamarinWorkshopLab2.MyClass();
                LabelWeather.Text = await myClass.GetWeather();

                //LabelDevice.Text = $"{UIKit.UIDevice.CurrentDevice.Name} {UIKit.UIDevice.CurrentDevice.Model}";//ios native相关的代码,不能放在PCL中
                LabelDevice.Text = myClass.GetDevice();
            };
        }
Beispiel #2
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            // TODO: Prepare page for display here.

            // TODO: If your application contains multiple pages, ensure that you are
            // handling the hardware Back button by registering for the
            // Windows.Phone.UI.Input.HardwareButtons.BackPressed event.
            // If you are using the NavigationHelper provided by some templates,
            // this event is handled for you.
            Button.Click += async delegate {
                XamarinWorkshopLab2.MyClass myClass = new XamarinWorkshopLab2.MyClass();
                tbWeather.Text = await myClass.GetWeather();

                Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation deviceInfo = new Windows.Security.ExchangeActiveSyncProvisioning.EasClientDeviceInformation();
                //tbDevice.Text = $"{deviceInfo.SystemManufacturer} {deviceInfo.FriendlyName}";//windows native相关代码,不能放在PCL中
                tbDevice.Text = myClass.GetDevice();
            };
        }
Beispiel #3
0
        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);

            button.Click += async delegate {
                XamarinWorkshopLab2.MyClass myClass = new XamarinWorkshopLab2.MyClass();

                TextView tvWeather = FindViewById <TextView>(Resource.Id.weather);
                tvWeather.Text = await myClass.GetWeather();

                TextView tvDevice = FindViewById <TextView>(Resource.Id.myDevice);
                //tvDevice.Text = $"{Android.OS.Build.Brand} {Android.OS.Build.Model}";//android native相关的代码,不能放在PCL中
                tvDevice.Text = myClass.GetDevice();
            };
        }