Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- }
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement