RobertApikyan / SegmentedControl

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

states when back to fragment #11

Closed alahammad closed 6 years ago

alahammad commented 6 years ago

Hello,

I face issue when i back to fragment the state of selectedAbsolutePosition is set to -1.

Is there any solution for this case..

Thanks,

RobertApikyan commented 6 years ago

Hi, Could you provide more details ... In general, selectedAbsolutePosition is -1 if no selected segment is selected.

RobertApikyan commented 6 years ago

SecmetedControl is in FragmentA , from FragmentA we open FragmentB, and when we come back to FragmentA the segmentedControl.getSelectedAbsolutePosition() returns -1. Is this the case ?

alahammad commented 6 years ago

yes this is the issue when back to fragment

RobertApikyan commented 6 years ago

Hi, Most probable you replace the FragmentA with FragmentB instead of adding FragmentB on FragmentA. After navigating back to FragmentA, it will be recreated ... That is why segmented control's absolute position is -1. Could you provide fragment transaction code snippet for navigating from FragmentA to FragmentB ?

RobertApikyan commented 6 years ago

By the way here is the working example with specified scenario SegmentedControllSupport.zip

alahammad commented 6 years ago

Hi,

Actually I use the new navigation component in jetpack, so i think it's replace fragment with another.

RobertApikyan commented 6 years ago

Yes... exactly, It's makes fragment replacement instead of adding them to one on another...