How can I clear Editext when a button is clicked?

时间:2019-03-19 14:38:17

标签: android xamarin.android mvvm-light

    public class LoginPageActivity : ActivityBase
    {

        private LoginViewModel loginViewModel
        {
            get { return App.Locator.loginViewModel; }
        }

        public readonly List<Binding> _bindings = new List<Binding>();
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.LoginPage);
            loginPageButton.Enabled = false;
            loginPageButton.Clickable = false;
//            EditText customerEntry = FindViewById<EditText>(Resource.Id.simpleEditText);

            _bindings.Add(this.SetBinding(() => customerEntry.Text, () => loginViewModel.CustomerNumber, BindingMode.TwoWay));
            //_bindings.Add(this.SetBinding(
            //    () => loginPageButton.Enabled,
            //    () => loginViewModel.IsEnabled, BindingMode.TwoWay));
            _bindings.Add(this.SetBinding(() => progressBar, () => loginViewModel.progressBar, BindingMode.TwoWay));

            loginPageButton.SetCommand(
                "Click",                
                loginViewModel.LoginButtonCommand);                 

        }


        private Button _loginPageButton;

        public Button loginPageButton
        {
            get
            {

                return _loginPageButton
                       ?? (_loginPageButton = FindViewById<Button>(Resource.Id.loginButton));                
            }

        }

        private EditText _customerEntry;

        public EditText customerEntry
        {
            get
            {
                return _customerEntry
                       ?? (_customerEntry = FindViewById<EditText>(Resource.Id.simpleEditText));
            }
        }

        private ProgressBar _progressBar;

        public ProgressBar progressBar
        {
            get
            {
                return _progressBar
                       ?? (_progressBar = FindViewById<ProgressBar>(Resource.Id.progressBar));
            }
        }
    }
}

I want to clear my edittext field when a button is clicked. I already try to do with on change listener but its not working in C#.

How can I do that using MVVMLight?

0 个答案:

没有答案