Open shubhams opened 7 years ago
<com.appyvet.rangebar.RangeBar xmlns:custom="http://schemas.android.com/apk/res-auto" android:id="@+id/rangebar1" android:layout_width="match_parent" android:layout_height="72dp" android:layout_marginLeft="16dp" android:layout_marginRight="16dp" custom:pinMaxFont="10sp" custom:selectorBoundaryColor="@color/accent" custom:selectorBoundarySize="2dp" custom:selectorSize="10dp" custom:temporaryPins="false" custom:tickEnd="80000" custom:tickInterval="1000" custom:tickStart="1000"/> not working
You can do it programmatically, like this:
rangeBar.setPinTextFormatter(new RangeBar.PinTextFormatter() {
@Override
public String getText(String value) {
return value;
}
});
I set the
tickEnd
andtickStart
values as:Now, to get the pin values I was using the
setOnRangeBarChangeListener
. The left pin value was coming out to be correct as1000
, however the right pin value was also coming out to be1000
.So, I peeked into the method of
getPinValue(int tickIndex)
and I noticed that before returning the value,mPinTextFormatter
is used to format the pin value. ThemPinTextFormatter
is defined as:The
if
condition to check if length is greater than 4, returns the substring upto the length 4.Although I fixed the issue by setting by own
PinTextFormatter
that returns the string value as it is, and it might make sense to return the "substring" when showing the value in the pin bubble.However, a simple
rangeBar.getRightPinValue()
would also give the wrong value in this case.