3 回答
TA贡献1869条经验 获得超4个赞
Xamarin Forms 有一些选项可以从堆栈中删除或添加页面。看看Navigation.PopAsync
或Navigation.RemovePage
。
TA贡献1834条经验 获得超8个赞
根据你如何描述你的目标,我认为这this.Finish();会很有魅力。
示例代码:
Button nextPage;
protected override void OnCreate(Bundle savedInstanceState)
{
try
{
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
SetContentView(Resource.Layout.your_content_xml);
// Set our view from the "main" layout resource
nextPage = FindViewById<Button>(Resource.Id.button1);
nextPage.Click += (s, e) =>
{
Intent nextActivity = new Intent(this, typeof(next_page_CS_file)); // Create Intent instance
StartActivity(nextActivity); // Go to the Next Page as set in Intent
this.Finish(); // Terminates Current Page.
// As such, once you're in the next page, clicking the back button
// on phone's menu will close the App instead of going back here
};
} catch (Exception ex)
{
// Any code you want that'll handle the Exception.
// Like, for example, . . .
Toast.MakeText(this, ex.ToString(), ToastLength.Short).Show();
}
}
根据我的理解和经验,这应该可行。但是,我不确定是否还有其他方法可以实现您的目标。
- 3 回答
- 0 关注
- 215 浏览
添加回答
举报