Wuhu Wuhu - 4 months ago 22
Android Question

GetText() doesn't work for me on EditText

i am using xaamarin i want to get edit text text

String us= ((EditText)findViewById(Resource.id.usr)).getText().toString();
String pw = ((EditText)findViewById(Resource.id.psw)).getText().toString();
String value1=us;
String value2=pw


when i use GetText() << it is erroring me
'Android.Widget.EditText' does not contain a definition for 'getText' and no extension method 'getText' accepting a first argument of type 'Android.Widget.EditText'

Answer

Setter and getter like setXYZ, getXyz are mapped to the property Xyz in Xamarin, because this is more C#-like.

var us = FindViewById<EditText>(Resource.Id.usr).Text;
Comments