Skip to content
Snippets Groups Projects
Commit f73aa687 authored by Peter Joseph De Jonckheere CESM2014's avatar Peter Joseph De Jonckheere CESM2014
Browse files

Added progress listener and text view for seek bar in settings.

parent c874d1c6
No related branches found
No related tags found
No related merge requests found
......@@ -66,9 +66,36 @@ public class Settings extends AppCompatActivity{
startActivity(intent);
}
});
setUpSeekBar();
populateSpinner();
}
private void setUpSeekBar(){
SeekBar bar = ((SeekBar)findViewById(R.id.seekBar2));
bar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
private TextView progressText;
{
progressText = ((TextView) findViewById(R.id.seekBarValue));
}
@Override
public void onProgressChanged(SeekBar bar, int progress, boolean fromUser) {
int val = (progress * (bar.getWidth() - 2 * bar.getThumbOffset())) / bar.getMax();
progressText.setText("" + progress);
progressText.setX(bar.getX() + val + bar.getThumbOffset() / 2);
}
@Override
public void onStartTrackingTouch(SeekBar bar){
progressText.setVisibility(View.VISIBLE);
}
@Override
public void onStopTrackingTouch(SeekBar bar){
progressText.setVisibility(View.INVISIBLE);
}
});
}
private void populateSpinner(){
Spinner spinner = findViewById(R.id.PeriodSpinner);
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.notification_periods, android.R.layout.simple_spinner_dropdown_item);
......
......@@ -167,4 +167,14 @@
app:layout_constraintStart_toEndOf="@+id/textView8"
app:layout_constraintTop_toBottomOf="@+id/Vibration" />
<TextView
android:id="@+id/seekBarValue"
android:layout_width="36dp"
android:layout_height="33dp"
android:layout_marginStart="8dp"
android:text="TextView"
android:visibility="invisible"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/seekBar2" />
</android.support.constraint.ConstraintLayout>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment