Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the value from EditText in android?

Tags:

android

I'm having one EditText in android in which I want the user to enter the text I'll store the db. But, here I am not able to get the value from EditText.

Here is my code,

EditText etUserInfoNewValue = (EditText)findViewById(R.id.etUserInfoNewVal);    
String newValue = etUserInfoNewValue.getText().toString().trim();

How can I get the value from this EditText?

like image 725
Lavanya Avatar asked Dec 27 '12 08:12

Lavanya


1 Answers

Put

String newValue = etUserInfoNewValue.getText().toString().trim(); 

Inside the button's onClicklistener().

You have put this code in onCreate() just after declaring it, it won't have any value at all. So you will get null value.

like image 190
MysticMagicϡ Avatar answered Sep 28 '22 06:09

MysticMagicϡ