Example #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            /*
             * // Set our view from the "main" layout resource
             * SetContentView(Resource.Layout.Main);
             * // http://217.117.27.42:8090/internal/api/product/1
             * this.client.BaseAddress = new Uri("http://217.117.27.42:8090/internal/");
             * this.client.MaxResponseContentBufferSize = 250000;
             * this.client.DefaultRequestHeaders.Accept.Clear();
             * this.client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
             */
            // Get our button from the layout resource,
            // and attach an event to it
            Button button = FindViewById <Button>(Resource.Id.MyButton);

            // button.Click += delegate { button.Text = string.Format("{0} clicks!", count++); };

            AsyncProductServices prservices = new AsyncProductServices();

            button.Click += async(sender, args) =>
            {
                //   EditText editID = FindViewById<EditText>(Resource.Id.editTextID);

                // int product_id = Int32.Parse("1");

                var prod = await prservices.GetProductAsync();

                //  EditText editName = FindViewById<EditText>(Resource.Id.editTextName);

                if (prod != null)
                {
                    button.Text = prod.Name;
                }
                else
                {
                    button.Text = "try again...";
                }
            };
        }
        static async Task RunAsync()
        {
            AsyncProductServices services = new AsyncProductServices();

            productList = await services.GetProductListAsync();
        }