Get Value of a Edit Text field
By using getText():
Button mButton;EditText mEdit;/** Called when the activity is first created. */@Overridepublic void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.main); mButton = (Button)findViewById(R.id.button); mEdit = (EditText)findViewById(R.id.edittext); mButton.setOnClickListener( new View.OnClickListener() { public void onClick(View view) { Log.v("EditText", mEdit.getText().toString()); } });}
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.
Get value from an EditText
control in android. EditText
getText
property use to get value an EditText
:
EditText txtname = findViewById(R.id.name);String name = txtname.getText().toString();