抱歉,如果这看起来很简单,但我查看了有关对话框的 N+1 视频,它显示了在代码中而不是通过使用布局来创建对话框。
这是我所做的:
ChangePasswordView.axml:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:local="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="16dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<EditText
android:id="@+id/oldpassword"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="@string/YourOldPassword"
android:inputType="textPassword"
local:MvxBind="Text OldPassword" />
<EditText
android:id="@+id/newpassword"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:hint="@string/YourNewPassword"
local:MvxBind="Text NewPassword" />
<Button
android:text="@string/ChangePassword"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
local:MvxBind="Click ChangePasswordCommand"
android:paddingRight="42dp"
android:paddingLeft="42dp" />
</LinearLayout>
</FrameLayout>
ChangePasswordView.cs:
[Activity]
public class ChangePasswordView : MvxDialogActivity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
DroidResources.Initialise(typeof(Resource.Layout));
this.SetContentView(Resource.Layout.ChangePassword);
}
}
从视图模型调用对话框的显示:
void ChangePassword()
{
this.ShowViewModel<ChangePasswordViewModel>();
}
我也有 Setup.cs:
public class Setup : MvxAndroidDialogSetup
{
...
}
运行导致错误抱怨:
Your content must have a ListView whose id attribute is 'android.R.id.list