mk-toolブログ

エンジニアと家のことをごちゃごちゃと書いてます

【Xamarin】邪道だけど試してみる2

このサイトを試してみたかったけど、どうやるかわからなかったから備忘的にメモ。
なぜか自分の作ったソリューションには「App.cs」が存在しない。。。
どうすれば良いのだ。まだ自分で作り上げていく能力がないというのに。
しかしながら、ActivityIndicatorに関して言えば、いろいろ設定値を決めて、最後にContentに代入しているといことは、もしや
と思ってやってみたらちゃんと動きました。
まず、初期時の「ソリューション名.cs」のAppメソッドを見てみる(というかここしか使わない)。

		public App ()
		{
			// The root page of your application
			MainPage = new ContentPage {
				Content = new StackLayout {
					VerticalOptions = LayoutOptions.Center,
					Children = {
						new Label {
							XAlign = TextAlignment.Center,
							Text = "Welcome to Xamarin Forms!"
						}					}
				}
			};
		}

ActivityIndicatorはContentに収まるということなので、おそらくこうではないかと、

		public App ()
		{
			// The root page of your application
			MainPage = new ContentPage {
				Content = new StackLayout {
					VerticalOptions = LayoutOptions.Center,
					Children = {
						new Label {
							XAlign = TextAlignment.Center,
							Text = "Welcome to Xamarin Forms!"
						},
						new ActivityIndicator {
							Color = Device.OnPlatform(Color.Black, Color.Default, Color.Default), 
							IsRunning = true, // 回転中
							VerticalOptions = LayoutOptions.CenterAndExpand // 中央に配置する
						}
					}
				}
			};
		}

ということをしたら、以下のようになりましたね。
これはいつ使うのだろう。レスポンスが返ってくるまで、これを表示して、レスポンスが来たらちゃんとしたページに
移動させるみたいな処理が入るのかな。。。
f:id:gamushiroS:20160511180035p:plain

とりあえずこれでよし。
その次もどんどん進もう。