0

Im realitve new in Android and Java programming. Actual im programming an App for some Calculation. I need multiple input validation (actv, spinner, edittext) to enable a Button. For ACTV Valdation i found this: Android, Autocomplettextview, force text to be from the entry list and get it to work with the Strings only. For my ACTV i have an Arraylist over OOP (Obejcts with multiple atributes) and i dont get it to work for me. I got only the first item from the List and when i switch to next EditText the actv field wwent to empty. I hope someone can tell where my failure is in the loop or has an actual example for an ACTV Validator. I have to compare the input with the names of the Arraylist object names. Big Thx!

myactv.setValidator(new AutoCompleteTextView.Validator() {
        @Override
        public boolean isValid(CharSequence text) {

            boolean result = false;

            for (MyObject myobject : mylist) {
                if (myobject.getName().toLowerCase().contains(String.valueOf(text).toLowerCase().trim())) {
                    Toast.makeText(MainActivity.this, "correct input!", Toast.LENGTH_SHORT).show();
                    result = true;                        
                }
            }
            return result;
        }

        @Override
        public CharSequence fixText(CharSequence invalidText) {myactv.setError("invalid")
            return null;
        }
    });
TheWorm
  • 9
  • 2

0 Answers0