[mono-android] Tutorials problem

Jonathan Pryor jonp at xamarin.com
Wed Dec 14 11:45:22 EST 2011


On Dec 14, 2011, at 10:56 AM, Tom wrote:
> I cannot run this sample
> http://docs.xamarin.com/android/tutorials/User_Interface/form_elements/edit_text
> 
> Error CS0079: The event 'Android.Views.View.KeyPress' can only appear on the
> left hand side of += or -= (CS0079) (CustomButton)

Sorry, that broke with the 4.0.0 API changes. I have updated the sample; it should be:

	EditText edittext = FindViewById<EditText>(Resource.Id.edittext);

	edittext.KeyPress += (object sender, View.KeyEventArgs e) => {
		if (e.E.Action == KeyEventActions.Down && e.KeyCode == Keycode.Enter) {
			Toast.MakeText (this, edittext.Text, ToastLength.Short).Show ();
			e.Handled = true;
		}
	};

Thanks,
 - Jon



More information about the Monodroid mailing list