Get Value of a Edit Text field in Android

XML Button Code
[code language=”css”]
<EditText android:id="@+id/name" android:width="250px" />

Java Code to get the value of Edit Text
[code language=”css”]
down vote accepted

By using getText():

Button mButton;
EditText mEdit;

/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState)

mButton = (Button)findViewById(R.id.button);
mEdit = (EditText)findViewById(R.id.name);

new View.OnClickListener()
public void onClick(View view)
Log.v("EditText", mEdit.getText().toString());


Sandeep Kumar

Sandeep kumar is a web developer and a professinal blogger. He works for latest technologies and write articles what he learn. In ICodeHub he share web languages tutorials and other programming tips and tricks. if you need some help or have some suggestion then mail him at sandeep92pal@gmail.com without any hesitation. He believes in learning and sharing.