Note that there are some explanatory texts on larger screens.

plurals
  1. POChange SeekBar progress based on EditText value
    text
    copied!<p>I am trying to change the progress of a <code>SeekBar</code> based on the number entered in an <code>EditText</code> but for some reason the <code>EditText</code> value goes to the max and I can't slide the thumb in the <code>SeekBar</code>.</p> <p>What I am looking to achieve: If the value entered in the <code>EditText</code> anywhere between 70 and 190 (including both number) change the progress of the <code>SeekBar</code> to that value.</p> <p>Partial Java code:</p> <pre><code>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) &gt;= 70 &amp;&amp; Integer.parseInt(filtered_str) &lt;= 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) {} }); </code></pre> <p>The partial XML:</p> <pre><code>&lt;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" /&gt; </code></pre> <p>I add 70 to each value, because <code>SeekBar</code> starts at 0, but I want it to start at 70.</p> <p>After using the above code, this is what it looks like:</p> <p><img src="https://i.stack.imgur.com/1WHQ6.png" alt="enter image description here"></p> <p>The <code>SeekBar</code> is at the maximum number and the <code>EditText</code> is at the maximum as well.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload