arcadefire / nice-spinner

A nice spinner for Android
Apache License 2.0
2.85k stars 445 forks source link

Maybe Spinner Text Formatter can be upgraded #106

Open houyuehai opened 5 years ago

houyuehai commented 5 years ago

Good library,Thinks. my data may not be String, it may be a student object, I want to show the name of the Student, but when I choose, I want to get the ID of the student from the listener. Because name is what the user sees, and ID is what the server needs. Maybe Spinner Text Formatter can be upgraded.

public interface SpinnerTextFormatter < T > { Spannable format(T var1); }

houyuehai commented 5 years ago

and if return null,do not draw item

yusufceylan commented 5 years ago

It merged but still only can be use for String, can not override

 SimpleSpinnerTextFormatter textFormatter = new SimpleSpinnerTextFormatter() {
            @Override
            public Spannable format(Object item) {
                Person person = (Person) item;
                return new SpannableString(person.getName() + " " + person.getSurname());
            }
        };

Still force me to Override

            @Override
            public Spannable format(String text) {
                return super.format(text);
            }
arcadefire commented 5 years ago

This should be possible now: aa42151f2578598a3bde8cf94c88eeea62f5c30d.