Question

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

Was it helpful?

Solution

String valuesz = et.getText().toString();
String valuez2 = et2.getText().toString();
boolean found = (valuez.contains(valuez2));
if (found)
    Log.d(TAG, "found");
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top