• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Java issue

brentc

Newbie
The following Java code:

if (txtEmail.toString().indexOf('@' , 0) == -1) {
showSnackbar("Test Invalid Email");
}

It executes showSnackbar when there IS an @ in the txtEmail input field.. Why?

Thank you anyone for your help.
 
If I do this:

if ("Test@ String".indexOf("@" ) == -1) {
showSnackbar("Invalid Email");
}

showSnackbar() does not get executed. It works OK.

So...It is the txtEmail.toString that is causing the problem. Could it be the Java compiler's fault??
 
I do this:

txtEmail = findViewById(R.id.txtEmail);

and the value of txtEmail does not get transfered.. Why not?
 
Back
Top Bottom