今週は、C#を学んでいて、アプリを作りました。私はそれが私がコードの先頭に戻る必要があることがわかったoriganalレイアウトに私を送り返したいと思う。事前にthx。Android C#xamarin help!コードの先頭に戻るにはボタンが必要です
namespace TheAppOfJack
{
[Activity(Label = "The App Of Jack", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
int count = 1;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
Button button1 = FindViewById<Button>(Resource.Id.MyButton);
button1.Click += delegate { button1.Text = string.Format("You have clicked this random button {0} times (͡° ͜ʖ ͡°)", count++); };
Button button2 = FindViewById<Button>(Resource.Id.button1);
button2.Click += delegate
{
SetContentView(Resource.Layout.Gallery);
Button button3 = FindViewById<Button>(Resource.Id.back);
button3.Click += delegate { SetContentView(Resource.Layout.Main); };
Button button4 = FindViewById<Button>(Resource.Id.next1);
button4.Click += delegate
{
SetContentView(Resource.Layout.Gallery2);
button3.Click += delegate { SetContentView(Resource.Layout.Main); };
Button button5 = FindViewById<Button>(Resource.Id.next2);
button5.Click += delegate
{
SetContentView(Resource.Layout.Gallery3);
Button button6 = FindViewById<Button>(Resource.Id.home);
button6.Click += delegate {
//this is where i want the code to send me back to the top };
};
};
};
}
}
}
あなたは何を達成しようとしていますか? (なぜ、あなたはトップに戻るのですか?) 'for'ループは必要なものを行いますか? –
私はコードレイアウトの先頭に戻る必要があります。なぜなら、私はそれをメールレイアウトに戻しただけなので、ブトンコードはまったく機能しません。これがforループで解決できるのであれば、それを使用したことのないiveとして私のコードに入れて、どこから始めるべきかわからないでしょう。 thx –
あなたがしようとしていることは、Androidアーキテクチャにとって非常に相反するものだと思います。私は、あなたがしたいことに似たサンプルプロジェクトを見つけて勉強しなければならないと思います。 –