[mono-android] I'm just not getting this - why is it a null reference?
Jonathan Pryor
jonp at xamarin.com
Wed Nov 30 15:35:28 EST 2011
On Nov 20, 2011, at 6:13 PM, Paul F. Johnson wrote:
> I then try and retrieve the data using the following and it gives me a
> null reference...
>
> EditText editText = FindViewById<EditText>(Resource.Id.tempSurround);
> if (editText.Text == "")
> {
> // fail
> }
FindViewById() will return null if you haven't called SetContentView() first, and if the specified resource ID isn't valid for the current content view. Have you called SetContentView() on the activity before calling FindViewById()?
Thanks,
- Jon
More information about the Monodroid
mailing list