0

I am trying to get text from an EditText in android but I have an Error:

Object reference not set to an instance of an object

I tried to look for a solution online, but I didn't find any. I just need to get the text from the EditText and pass it to a string

My code:

EditText edip = FindViewById<EditText>(Resource.Id.editText1);
EditText edport = FindViewById<EditText>(Resource.Id.editText2);

string customip = edip.Text;
string customport = edport.Text;
Athafoud
  • 2,898
  • 3
  • 40
  • 58
Ingmar05
  • 501
  • 2
  • 8
  • 25
  • 1
    Are you sure that editText1 and editText2 are in your view? Which stage of the app lifecycle is your code? – Kris Krause Jan 06 '16 at 22:39
  • Possible duplicate of [What does "Object reference not set to an instance of an object" mean?](http://stackoverflow.com/questions/779091/what-does-object-reference-not-set-to-an-instance-of-an-object-mean) – T.S. Jan 07 '16 at 00:22

1 Answers1

0

Try :

EditText edip = (EditText)FindViewById(Resource.Id.editText1);

... should work fine.

Dome
  • 1