【问题标题】:Pop a page from stack从堆栈中弹出一个页面
【发布时间】:2017-10-30 10:12:35
【问题描述】:

我正在尝试从主页(在共享代码中)导航到详细信息页面(在 droid、本机代码中)。当有人按下接受按钮时,我想删除详细信息页面并返回主页。 Navigation.PopAsync() 对我不起作用。

【问题讨论】:

  • 如果你用 Navigation.PushAsync() 来打开最后一页;你可以使用 PopAsync。但可能你打开了另一种方法。你分享你的传递页面代码吗?
  • 你是如何从首页导航到详情页的?

标签: xamarin xamarin.forms xamarin.android


【解决方案1】:

我正在尝试从主页(在共享代码中)导航到详细信息页面(在 droid、本机代码中)。

据我了解,您的详细信息页面(在 droid 本地代码中)是Activity。您需要使用DependencyServiceXamarin.Forms 打开一个Activity。 你可以阅读我关于Start an Android activity in Xamarin Forms 的回答。

当有人按下接受按钮时,我想删除详细信息页面并返回主页。

你只需要关闭新打开的Activity,例如:

public class NativeActivity : Activity
{
    protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);

        SetContentView(Resource.Layout.native_layout);
        Button native_bt = FindViewById<Button>(Resource.Id.native_bt);
        native_bt.Click += (s, e) =>
        {
            //close the current Activity and go back to the Home Page.
            this.Finish();
        };
    }
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-03-20
    • 2019-08-08
    • 2021-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-06
    • 2014-12-30
    相关资源
    最近更新 更多