Hi I\'m a newbie in Android Programming.
I\'m trying to build an activity which includes an edittext
field and a button
. When user type in an
You can use TextWatcher
for EditText
to get value of every change in EditText
.You need to add interface of TextWatcher in your Activity.
mEditText.addTextChangedListener(Your Class Name.this);
on in method of TextWatcher
@Override
public void afterTextChanged(Editable s) {
Log.v("Log_tag", "After TextChanged" + s.toString());
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
Log.i("Log_tag", "Before TextChanged" + s.toString());
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
Log.e("Log_tag", "ontext Changed" + s.toString());
//you can match here s with number or integer
if(isNumeric( s.toString())){
//it is number
}
}
public static boolean isNumeric(String str)
{
return str.matches("-?\\d+(.\\d+)?");
}