RobertApikyan / SegmentedControl

Android SegmentedControl + multi row support
Apache License 2.0
162 stars 30 forks source link

How can make it multi select? #23

Closed smae1993 closed 5 years ago

smae1993 commented 5 years ago

How can i make this project multi selectable?

wann2 commented 5 years ago

Me too. I'd also like to know how I can make it multi select.

RobertApikyan commented 5 years ago

it's a good idea, will add such a functionality most probably on this weekend

wann2 commented 5 years ago

When can I please expect to use multi select function?

RobertApikyan commented 5 years ago

sorry for delay, will try to publish a new version till the end of day

wann2 commented 5 years ago

Thanks for your kindness. Your library is very good! It would be better if we could get the values of the items selected from the list.

RobertApikyan commented 5 years ago

Here is the new version of segmented control that supports multi selection.

implementation 'com.github.RobertApikyan:SegmentedControl:1.2-alpha'

For enabling multi selection use setSupportedSelectionsCount(int) programmatically and supportedSelectionsCount attribute from XML (default value is 1). it works in following way, if supportedSelectionCount = 3, then maximum 3 items can be in selected state at the same time, when the new item is selected the oldest selection become unselected.

For now it's in alpha release, please let me know if any problems will occur

wann2 commented 5 years ago

Thank you very much. I think it will help a lot.

wann2 commented 5 years ago

Hi, When I use "segmented_control.notifyConfigIsChanged();", the follow exception happens. So I used try catch and no problem. This might help you to improve the source codes.

java.util.NoSuchElementException at java.util.LinkedList.getLast(LinkedList.java:257) W/System.err: at segmented_control.widget.custom.android.com.segmentedcontrol.SegmentedControlControllerComponent.getLastSelectedViewHolder(SegmentedControlControllerComponent.java:103) W/System.err: at segmented_control.widget.custom.android.com.segmentedcontrol.SegmentedControlControllerComponent.recreate(SegmentedControlControllerComponent.java:201) W/System.err: at segmented_control.widget.custom.android.com.segmentedcontrol.SegmentedControlControllerComponent.notifyConfigIsChanged(SegmentedControlControllerComponent.java:156) W/System.err: at segmented_control.widget.custom.android.com.segmentedcontrol.SegmentedControl.notifyConfigIsChanged(SegmentedControl.java:620)

Many thanks.

RobertApikyan commented 5 years ago

Hi, thanks for reporting the issue, now it's fixed, here is the new version's dependency implementation 'com.github.RobertApikyan:SegmentedControl:1.2.0.1-alpha'

RobertApikyan commented 5 years ago

Hi, I am closing the issue, if any problem will occur please fill free to reopen it