Android应用程序在C#中,Toast消息 - XAMRIN

时间:2015-11-03 18:33:38

标签: c# android xamarin xamarin.android toast

所以我试图做一个简单的应用程序。我首先通过登录表单开始。

问题是toast消息不会显示。我今天早些时候做了它,但是混淆了。我是C#for android的新手,非常感谢你的帮助。

用户名设置为电子邮件类型:dude@gmail.com 密码设置为密码类型:example123

toast被定义为welcome,没有在实际声明中调用的Show方法。

以下是代码:

    using System;

using Android.App;
using Android.Content;
using Android.Runtime;
using Android.Views;
using Android.Widget;
using Android.OS;

namespace VancersLoginBotV1
{
    [Activity (Label = "VancersLoginBotV1", MainLauncher = true, Icon = "@drawable/icon")]
    public class MainActivity : Activity
    {


        protected override void OnCreate (Bundle bundle)
        {
            base.OnCreate (bundle);

            // Set our view from the "main" layout resource
            SetContentView (Resource.Layout.Main);

            // Get our button from the layout resource,
            // and attach an event to it

            Button btnlogin = FindViewById<Button> (Resource.Id.button1);
            EditText txtEmail = FindViewById<EditText> (Resource.Id.editText1);
            EditText txtPassword = FindViewById<EditText> (Resource.Id.editText2);




            btnlogin.Click += (object sender, EventArgs e) => 
            {
                Toast welcome = Toast.MakeText (this, "Welcome to the application", ToastLength.Short);
                if (txtEmail.Text == "dude@gmail.com" && txtPassword.Text == "example123")      
                {
                    welcome.Show();
                }


            };

        }
    }
}

0 个答案:

没有答案