Android only allows one navigation page on screen at a time using

十年热恋 提交于 2020-01-11 04:42:07

问题


what is the difference between 2 implementations below?

 public App()
    {
        // The root page of your application
        MainPage = new Views.MainPage();
    }   
 public App()
    {     
        MainPage = new NavigationPage(new MainPage());
    }

if my main page inherits MasterDetailPage, 1st code above will work but 2nd one will return error message telling me that "android only allows one navigation page on screen at a time" when I debug my android app.

  public class MainPage : MasterDetailPage
    {

        MasterPage masterPage;
        public MainPage()
        {
            masterPage = new MasterPage();
            Master = masterPage;
            Detail = new NavigationPage(new AnotherPage());

回答1:


I might be a bit confused by what you are asking but if you are doing

MainPage = new NavigationPage(new MainPage());

And your MainPage is

public class MainPage : MasterDetailPage
{

    MasterPage masterPage;
    public MainPage()
    {
        masterPage = new MasterPage();
        Master = masterPage;
        Detail = new NavigationPage(new AnotherPage());

Then you are doing

NavigationPage > MasterDetailPage > NavigationPage

Either MasterDetail or Navigation should be the root and not have them inside each other. You can't have 2 navigation pages within each other.



来源:https://stackoverflow.com/questions/34406620/android-only-allows-one-navigation-page-on-screen-at-a-time-using

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!