I am learning how to create UI elements. I have created a few EditText input fields. On the click of a Button I want to capture the content typed into that input field.
<EditText android:id="@+id/name" android:width="220px" />
That's my field. How can I get the content?
A more advanced way would be to use butterknife bindview. This eliminates redundant code.
In your gradle under dependencies; add this 2 lines.
Then sync up. Example binding edittext in MainActivity
But this is an alternative once you feel more comfortable or starting to work with lots of data.
I hope this one should work:
I tried
Integer.getInteger()
method instead ofvalueOf()
- it didn't work.I guess you will have to use this code when calling the "mEdit" your EditText object :
myActivity.this.mEdit.getText().toString()
Just make sure that the compiler know which
EditText
to call and use.