Zmień postęp SeekBar na podstawie wartości EditText
Próbuję zmienić postępySeekBar
na podstawie numeru wpisanego wEditText
ale z jakiegoś powoduEditText
wartość idzie do maksimum i nie mogę przesunąć kciuka wSeekBar
.
Co chcę osiągnąć: Jeśli wartość wprowadzona wEditText
w dowolnym miejscu pomiędzy 70 a 190 (w tym obie liczby) zmieniają postępSeekBar
do tej wartości.
Częściowy kod Java:
etOne = (EditText) findViewById(R.id.etSyst);
etOne.addTextChangedListener(new TextWatcher() {
public void afterTextChanged(Editable s) {
String filtered_str = s.toString();
if (Integer.parseInt(filtered_str) >= 70 && Integer.parseInt(filtered_str) <= 190) {
sbSyst.setProgress(Integer.parseInt(filtered_str));
}
}
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
public void onTextChanged(CharSequence s, int start, int before, int count) {}
});
Częściowy XML:
<SeekBar
android:id="@+id/syst_bar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:progress="0"
android:max="120"
android:progressDrawable="@drawable/progress_bar"
android:secondaryProgress="0"
android:thumb="@drawable/thumb_state" />
Dodaję 70 do każdej wartości, ponieważSeekBar
zaczyna się od 0, ale chcę, żeby zaczynał od 70.
Po użyciu powyższego kodu wygląda tak:
TheSeekBar
jest na maksymalnej liczbie iEditText
jest również na maksimum.