Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi.., this is my first project of android using xamarin and I am not able to access value from EditText in my code.

What I have tried:

EditText username = FindViewById<edittext>(Resource.Id.editTextUsername);
EditText password = FindViewById<edittext>(Resource.Id.editTextPassword);
// Store EditText in Variable

string strusername = username.ToString();
// string strusername = username.getText().ToString(); (getText() method not found)
string strpassword = password.ToString();


if (strusername == "nworks" && strpassword == "nworks") {
var showSecond = FindViewById<Button>(Resource.Id.buttonLOGIN);
showSecond.Click += (sender, e) =>
{
StartActivity(typeof(HomeActivity));

};
Posted
Updated 24-Feb-16 22:03pm

1 solution

You do not need to call ToString() on a text field, it is already a string. A call to getText() will return the string containing the item's text - see EditText | Android Developers[^].
 
Share this answer
 
Comments
Member 11914978 25-Feb-16 4:10am    
Sir but getText() method is not found in my solution.
Richard MacCutchan 25-Feb-16 6:57am    
According to the Java documentation that should work. You need to check the Xamarin version.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900