GunaseelanArumaikkannu / MultiSpinner

Spinner in android with multiple selections
http://v4all123.blogspot.com/2013/09/spinner-with-multiple-selection-in.html
31 stars 31 forks source link

setSelection(String[]) is missing selection reset and update to view #1

Closed maikthomas closed 8 years ago

maikthomas commented 8 years ago

Hi there, I added some code to setSelection(String[]) to reset the selection and update the view. Turns out the exact code I added was already in setSelection(List). Am i right in thinking that it has been left out accidentally?

This part:

    for (int i = 0; i < mSelection.length; i++) {
        mSelection[i] = false;
        mSelectionAtStart[i] = false;
    } 

and this

    simple_adapter.clear();
    simple_adapter.add(buildSelectedItemString());

Are missing.

public void setSelection(String[] selection) {
    for (String cell : selection) {
        for (int j = 0; j < _items.length; ++j) {
            if (_items[j].equals(cell)) {
                mSelection[j] = true;
                mSelectionAtStart[j] = true;
            } 
        } 
    } 
} 

public void setSelection(List<String> selection) {
    for (int i = 0; i < mSelection.length; i++) {
        mSelection[i] = false;
        mSelectionAtStart[i] = false;
    } 
    for (String sel : selection) {
        for (int j = 0; j < _items.length; ++j) {
            if (_items[j].equals(sel)) {
                mSelection[j] = true;
                mSelectionAtStart[j] = true;
            } 
        } 
    } 
    simple_adapter.clear();
    simple_adapter.add(buildSelectedItemString());
} 
GunaseelanArumaikkannu commented 8 years ago

Thank you Mikethomas. Added :+1: