0
因此,我一直在開發我的第一個應用程序,除了後退按鈕,一切都很順利。如何更改後退按鈕的導航android C#Xamarin
當你按回去做後退動畫,但它落在同一個活動,然後它關閉。 我想要它,所以當你按回去它主要活動(第一個(開始菜單))
在我的代碼中你可以ee,我嘗試添加noHistory = true,但那也沒有工作。
這裏是什麼樣子
這裏是(問題2),你可以看到,如果給我這個問題
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Views;
using Android.Widget;
namespace TestingFixes
{
[Activity(Label = "firstQ", NoHistory =true)]
public class firstQ : Activity
{
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.firstQDesign); // Change This
Button easyBtn3 = FindViewById<Button>(Resource.Id.oopBtn); //Change This
easyBtn3.Click += (object sender, EventArgs e) => { //Change This
easyBtn3.Click += delegate { //Change This
StartActivity(typeof(easySecondQ)); //Change This
SetContentView(Resource.Layout.easysecondQDesign); //Change This
//Would I maybe connect the text here to an int?
};
};
}
}
}
這裏是代碼在MainActivity(開始菜單中的代碼)
using System;
using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;
namespace TestingFixes
{
[Activity(Label = "TestingFixes", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
// Set our view from the "main" layout resource
SetContentView(Resource.Layout.Main);
Button easyBtn2 = FindViewById<Button>(Resource.Id.easyBtn);
easyBtn2.Click += (object sender, EventArgs e) => {
easyBtn2.Click += delegate {
StartActivity(typeof(firstQ));
SetContentView(Resource.Layout.firstQDesign);
//Would I maybe connect the text here to an int?
};
};
}
}
}
可能是因爲我真的分層,但我在哪裏添加? https://i.gyazo.com/828eb89423dd4572562f878ca5e84513.png – VargaDev
在你的Activity類中。你在哪裏添加onCreate()方法。 –
它不斷給我錯誤 – VargaDev