C# Xamarin,Android:使用复选框和一个“";“出生日期”;轮
我需要建立一个类似这样的警报:C# Xamarin,Android:使用复选框和一个“";“出生日期”;轮,c#,android,xamarin,C#,Android,Xamarin,我需要建立一个类似这样的警报: Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this); alert.SetTitle(""); alert.SetIcon(Resource.Drawable.general_btn_newlevel); alert.SetMessage(""); alert.SetPos
Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this);
alert.SetTitle("");
alert.SetIcon(Resource.Drawable.general_btn_newlevel);
alert.SetMessage("");
alert.SetPositiveButton("", (senderAlert, args) =>
{
StartActivity(typeof(Activity_WelcomeKao2));
});
Dialog dialog = alert.Create();
dialog.Show();
。。。我只需要在那里显示一个复选框(供用户接受一般业务条款)和某种“轮子”,用户可以在其中选择出生日期。我知道这可能需要一个自定义警报,但是,我在C#中找不到任何关于此的信息。任何帮助都会非常棒!
obs:这个出生日期是为了验证你是否达到法定年龄
谢谢:)我想我找到了一个简单的解决方案: 这段代码:
LayoutInflater lf = LayoutInflater.From(this);
View mView = lf.Inflate(Resource.Layout.Alert_CheckBox, null);
AlertDialog.Builder alert = new AlertDialog.Builder(this);
alert.SetView(mView);
alert.SetTitle("");
alert.SetPositiveButton(Resources.GetString(Resource.String.Finished), (senderAlert, args) =>
{
StartActivity(typeof(Activity_WelcomeKao2));
});
Dialog dialog = alert.Create();
dialog.Show();
与布局文件一起:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="250dp"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="20dp" />
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="0dp"
android:layout_weight="5"
android:layout_height="match_parent" />
<LinearLayout
android:orientation="vertical"
android:layout_width="0dp"
android:layout_weight="90"
android:layout_height="wrap_content">
<CheckBox
android:id="@+id/edt_checkbox_userinputalert"
android:layout_width="240dp"
android:layout_height="wrap_content"
android:hint="Accept AGBs" />
</LinearLayout>
<LinearLayout
android:layout_width="0dp"
android:layout_weight="5"
android:layout_height="match_parent" />
</LinearLayout>
</LinearLayout>
然后通过mView.findviewbyd从xml中引用对象
其实很简单
因此,我所做的就是与设计师一起构建布局,然后通过LayoutFlater将其膨胀。不需要定制的东西
至于日期选择器: