Pregunta

I have two edittexts, et and et2. What I want it to be seached if the string given from et2 is contained in et. I use:

                valuez = et.getText().toString();
                length = valuez.length();
                valuez2 = et2.getText().toString();
                length2 = valuez2.length();

                for (int i=0; i<length; i++) {
                    for (int j=0; j<length2; j++) {
                        if (valuez.charAt(i) != valuez2.charAt(j)) {
                            continue;
                        }
                        if (j == length2) {
                            System.out.println("Found");
                            break;
                        }
                    }
                }

But that doesn't seem to work. Any ideas? Thanks a lot

¿Fue útil?

Solución

String valuesz = et.getText().toString();
String valuez2 = et2.getText().toString();
boolean found = (valuez.contains(valuez2));
if (found)
    Log.d(TAG, "found");
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top