I'm at the very early stage of learning Android. Can anyone tell me how I can use the text written in a Text box by user?
I'm trying to use getText() method but finding it confusing.
Thanks in advance.
I'm at the very early stage of learning Android. Can anyone tell me how I can use the text written in a Text box by user?
I'm trying to use getText() method but finding it confusing.
Thanks in advance.
getText should do it.
you maybe need a string cast?
what is the code you using @ the moment?
example:
EditText editText = (EditText)findViewById(R.id.yourId);
String editTextStr = editText.getText().toString()
docs:
http://developer.android.com/reference/android/widget/TextView.html#getText(
yes you need to retrieve the text by using getText() method. What is it that you find confusing here?
In short you need to say Textview.getText()
i think you are looking for TextView
http://developer.android.com/reference/android/widget/EditText.html
getText
and setText
methods are avaialbe in this class to set and get text value.
I think what might be confusing him is that getText()
doesn't return a string. You have to do getText().toString()