Вопрос

I'm brainstorming the next phase of my project, and I'm not certain which path to take. My idea is to have 2 EditText fields, one beneath the other. When the user types a unique ID into the first field, the second field will populate automatically with corresponding text. For example, entering "X5432" in box 1 will put "1957 Thunderbird" in box 2. I estimate having about 500 value pairs to work from, so I assume a SQLite structure would be better than just using arrays. Any suggestions would be appreciated. Thanks.

Это было полезно?

Решение

I think you should use TextWatcher.

  1. Just get value from edittext1

  2. Find appropriate text for edittext2

  3. Set text to second edittext.

    edittext.addTextChangedListener(new TextWatcher() {
    
        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            // do some stuff
    
        }
    
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count,
                int after) {
            // do some stuff
    
        }
    
        @Override
        public void afterTextChanged(Editable s) {
            // do some stuff
    
        }
    });
    
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top