I use Ermodo Range Bar , and the fact is that I need to display the minimum value and the maximum value in hours and minutes ... That is, the type of this
.
The code itself:
public class FilterActivity extends Activity { private RangeBar rangebar; final int SMALLEST_HOUR_FRACTION = 1; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.filter_layout); final TextView mDepartMin = (TextView)findViewById(R.id.tvDepartMin); final TextView mDepartMax = (TextView)findViewById(R.id.tvDepartMax); rangebar = (RangeBar) findViewById(R.id.rangebar1); rangebar.setTickCount(25 * SMALLEST_HOUR_FRACTION); rangebar.setTickHeight(0); rangebar.setThumbRadius(8); rangebar.setConnectingLineWeight(3); mDepartMin.setText("" + (rangebar.getLeftIndex() / SMALLEST_HOUR_FRACTION) + ":" + SMALLEST_HOUR_FRACTION * (rangebar.getLeftIndex() % SMALLEST_HOUR_FRACTION)); mDepartMax.setText("" + (rangebar.getRightIndex() / SMALLEST_HOUR_FRACTION) + ":" + SMALLEST_HOUR_FRACTION * (rangebar.getRightIndex() % SMALLEST_HOUR_FRACTION)); rangebar.setOnRangeBarChangeListener(new RangeBar.OnRangeBarChangeListener() { @Override public void onIndexChangeListener(RangeBar rangeBar, int leftThumbIndex, int rightThumbIndex) { int minHour = leftThumbIndex / SMALLEST_HOUR_FRACTION; int minMinute = SMALLEST_HOUR_FRACTION * (leftThumbIndex % SMALLEST_HOUR_FRACTION); int maxHour = rightThumbIndex / SMALLEST_HOUR_FRACTION; int maxMinute = SMALLEST_HOUR_FRACTION * (rightThumbIndex % SMALLEST_HOUR_FRACTION); mDepartMin.setText(minHour + ":" + minMinute); mDepartMax.setText(maxHour + ":" + maxMinute); } }); } } Now it looks like this:
Please tell me how to change the format H: M to HH: MM?

Datetype (and convert it to the string of the desired type usingSimpleDateFormatbefore output), and not with theinttype. - pavlofffDate, how are you going to work with time and dates, using the typeint- pavlofffDateclass, or even more conveniently, with theCalendarclass β extract hours, minutes from it to specify values ββin theRangeBar, convert the date to the string of the desired type, and so on. and forward. Here's a look to start - pavlofff