我是Android的新手,有以下问题: 这是代码:
base.OnCreate(bundle);
var layout = FindViewById<LinearLayout>(Resource.Id.layout1);
Button butondata = FindViewById<Button>(Resource.Id.button3);
Button butonstartdate = FindViewById<Button>(Resource.Id.button4);
Button butonenddate = FindViewById<Button>(Resource.Id.button5);
EditText txtsubiect = FindViewById<EditText>(Resource.Id.editText1);
Button submit = FindViewById<Button>(Resource.Id.buttonsalveaza);
butondata.Click += butondata_Click;
submit.Click += (sender, e) =>
{
txtsubiect.TextChanged += (object sender1, Android.Text.TextChangedEventArgs f) =>
{
if (txtsubiect.Text.Length <= 0)
{
txtsubiect.RequestFocus();
txtsubiect.SetError("Eroare,camp gol!");
}
};
};
当我构建它时,我说:没有方法'SetError'的重载需要1个参数,这是错误的,因为我有点困惑,并且会出现错误信息吗? THX!
答案 0 :(得分:1)
您需要设置一个drawable以与错误消息一起显示。 它需要2个参数,第二个是Drawable,一个与消息一起显示的图标。
Drawable icon_error = Resources.GetDrawable(Resource.Drawable.icon_error);//this should be your error image.
icon_error.SetBounds(0,0,icon_error.IntrinsicWidth,icon_error.IntrinsicHeight);
if (txtsubiect.Text.Length <= 0)
{
txtsubiect.RequestFocus();
txtsubiect.SetError("Eroare,camp gol!", icon_error );
}