Open swatiomar opened 5 years ago
I solved it by implementing this little solution, hope it helps.
int preMin = -1;
int preMax = -1;
rangebar.setOnRangeBarChangeListener(new RangeBar.OnRangeBarChangeListener() {
@Override
public void onRangeChangeListener(final RangeBar rangeBar, int leftPinIndex,
int rightPinIndex, String leftPinValue, String rightPinValue) {
int diff = rightPinIndex - leftPinIndex;
if (diff < 3) {
rangebar.setEnabled(false);
if (leftPinIndex != preMin || rightPinIndex != preMax) {
rangeBar.setRangePinsByIndices(preMin, preMax);
}
AlertDialog.Builder alert = new AlertDialog.Builder(MainActivity.this);
alert.setNegativeButton(getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
rangeBar.setEnabled(true);
dialog.dismiss();
}
});
alert.setCancelable(true);
alert.setMessage(Html.fromHtml("Minimum range reached!!")).show();
} else {
preMin = leftPinIndex;
preMax = rightPinIndex;
}
// More of what you desire
}
@Override
public void onTouchEnded(RangeBar rangeBar) {
Log.d("RangeBar", "Touch ended");
}
@Override
public void onTouchStarted(RangeBar rangeBar) {
Log.d("RangeBar", "Touch started");
}
});
Any updates here? I also think having an option of overlap is great!
Setting minThumbDistance=1 did it for me.
Thanks for advice @akshay-nak . It worked for me :)
I want to prevent the overlapping issue. As Left slider don't pass the right slider or not overlap the right slider. How to do this?