gpt4 book ai didi

android - Xamarin 完全形成 Java.Lang.IllegalArgumentException : DrawerLayout must be measured with MeasureSpec.

转载 作者:行者123 更新时间:2023-11-29 17:33:58 24 4
gpt4 key购买 nike

我将 Auth0 与 Xamarin Forms PCL 库一起使用。我有以下 MainPage 类:

namespace LoginPattern
{
public class MainPage : MasterDetailPage
{
public MainPage ()
{
Master = new MenuPage ();
Detail = new DetailPage ();
}
}
}

然后在应用程序类中

public App ()
{
Current = this;

Login ();
}

public void ShowMainPage ()
{
MainPage = new MainPage ();
}

public async void Login ()
{
await DependencyService.Get<IAuth0WidgetLogin>().LoginUseAuth0EmbeddedWidget();
App.Current.Properties["IsLoggedIn"] = true;

ShowMainPage ();
}

因此,在登录时,我最初没有加载任何页面,除了 Auth0 登录小部件。成功登录后,我想显示 MasterDetailPage。但是出现以下错误:Java.Lang.IllegalArgumentException:必须使用 MeasureSpec.EXACTLY 测量 DrawerLayout。

请告知我是否需要在 NavigationPage 中加载 Widget 以及如何加载。

编辑 17 月 7 日:

public class MenuPage : ContentPage
{
MasterDetailPage master;

TableView tableView;

public MenuPage ()
{
Title = "LoginPattern";
Icon = "slideout.png";

var section = new TableSection () {
new TextCell {Text = "Sessions"},
new TextCell {Text = "Speakers"},
new TextCell {Text = "Favorites"},
new TextCell {Text = "Room Plan"},
new TextCell {Text = "Map"},
};

var root = new TableRoot () {section} ;

tableView = new TableView ()
{
Root = root,
Intent = TableIntent.Menu,
};

var logoutButton = new Button { Text = "Logout" };
logoutButton.Clicked += (sender, e) => {
App.Current.Logout();
};

Content = new StackLayout {
BackgroundColor = Color.Gray,
VerticalOptions = LayoutOptions.FillAndExpand,
Children = {
tableView,
logoutButton
}
};
}


}


public class DetailPage : ContentPage
{
public DetailPage ()
{
BackgroundColor = new Color (0, 0, 1, 0.2);

var text = "Slide > to see the master / menu";

if (Device.OS == TargetPlatform.Android) {
text = @"Click the action bar dots to see the master / menu";
} else if (Device.OS == TargetPlatform.WinPhone) {
text = @"Click button \/ to see the master / menu ";
}

Content = new StackLayout {
HorizontalOptions = LayoutOptions.Center,
Padding = new Thickness (10, 40, 10, 10),
Children = {

new Label { Text = text }
}
};
}
}

最佳答案

我会尝试做两件事:

  1. 在您尝试显示身份验证小部件之前,将应用程序的 MainPage 设置为空白页面(或启动页面之类的内容)。
  2. 在您的 MenuPage 上设置明确的宽度要求。

关于android - Xamarin 完全形成 Java.Lang.IllegalArgumentException : DrawerLayout must be measured with MeasureSpec.,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31460432/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com