Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HorizontalSpinner.java #15

Open
dimonbugor opened this issue Dec 30, 2022 · 1 comment
Open

HorizontalSpinner.java #15

dimonbugor opened this issue Dec 30, 2022 · 1 comment

Comments

@dimonbugor
Copy link

В HorizontalSpinner.java додайте

private void refreshChildItem(int index) {
....
if (index != mCurrentIndex) {
view.setOnClickListener(mOnClickListener);
} else {
view.setOnClickListener(mOnSwitchListener);
}
.....
}

@Vipul0052
Copy link

import android.content.Context;
import android.util.AttributeSet;
import android.widget.Spinner;

public class HorizontalSpinner extends Spinner {

public HorizontalSpinner(Context context) {
    super(context);
}

public HorizontalSpinner(Context context, AttributeSet attrs) {
    super(context, attrs);
}

public HorizontalSpinner(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
}

@Override
public void setSelection(int position, boolean animate) {
    boolean sameSelected = position == getSelectedItemPosition();
    super.setSelection(position, animate);
    if (sameSelected) {
        // Spinner does not call the OnItemSelectedListener if the same item is selected, so do it manually now
        getOnItemSelectedListener().onItemSelected(this, getSelectedView(), position, getSelectedItemId());
    }
}

@Override
public void setSelection(int position) {
    boolean sameSelected = position == getSelectedItemPosition();
    super.setSelection(position);
    if (sameSelected) {
        // Spinner does not call the OnItemSelectedListener if the same item is selected, so do it manually now
        getOnItemSelectedListener().onItemSelected(this, getSelectedView(), position, getSelectedItemId());
    }
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants