1. <tfoot id='wtGLs'></tfoot>

      <small id='wtGLs'></small><noframes id='wtGLs'>

      • <bdo id='wtGLs'></bdo><ul id='wtGLs'></ul>
    2. <legend id='wtGLs'><style id='wtGLs'><dir id='wtGLs'><q id='wtGLs'></q></dir></style></legend>
      <i id='wtGLs'><tr id='wtGLs'><dt id='wtGLs'><q id='wtGLs'><span id='wtGLs'><b id='wtGLs'><form id='wtGLs'><ins id='wtGLs'></ins><ul id='wtGLs'></ul><sub id='wtGLs'></sub></form><legend id='wtGLs'></legend><bdo id='wtGLs'><pre id='wtGLs'><center id='wtGLs'></center></pre></bdo></b><th id='wtGLs'></th></span></q></dt></tr></i><div id='wtGLs'><tfoot id='wtGLs'></tfoot><dl id='wtGLs'><fieldset id='wtGLs'></fieldset></dl></div>
    3. 根据 EditText 值更改 SeekBar 进度

      时间:2023-10-01

      • <i id='G7Apk'><tr id='G7Apk'><dt id='G7Apk'><q id='G7Apk'><span id='G7Apk'><b id='G7Apk'><form id='G7Apk'><ins id='G7Apk'></ins><ul id='G7Apk'></ul><sub id='G7Apk'></sub></form><legend id='G7Apk'></legend><bdo id='G7Apk'><pre id='G7Apk'><center id='G7Apk'></center></pre></bdo></b><th id='G7Apk'></th></span></q></dt></tr></i><div id='G7Apk'><tfoot id='G7Apk'></tfoot><dl id='G7Apk'><fieldset id='G7Apk'></fieldset></dl></div>
          <tbody id='G7Apk'></tbody>
      • <tfoot id='G7Apk'></tfoot>

        1. <small id='G7Apk'></small><noframes id='G7Apk'>

            • <bdo id='G7Apk'></bdo><ul id='G7Apk'></ul>

              1. <legend id='G7Apk'><style id='G7Apk'><dir id='G7Apk'><q id='G7Apk'></q></dir></style></legend>
                本文介绍了根据 EditText 值更改 SeekBar 进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我正在尝试根据在 EditText 中输入的数字来更改 SeekBar 的进度,但由于某种原因 EditText 值变为到最大,我无法在 SeekBar 中滑动拇指.

                I am trying to change the progress of a SeekBar based on the number entered in an EditText but for some reason the EditText value goes to the max and I can't slide the thumb in the SeekBar.

                我希望实现的目标:如果在 EditText 中输入的值介于 70 和 190 之间(包括两个数字),则将 SeekBar 的进度更改为该值.

                What I am looking to achieve: If the value entered in the EditText anywhere between 70 and 190 (including both number) change the progress of the SeekBar to that value.

                部分 Java 代码:

                Partial Java 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) >= 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) {}
                        });
                

                部分 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" />
                

                我给每个值加 70,因为 SeekBar 从 0 开始,但我希望它从 70 开始.

                I add 70 to each value, because SeekBar starts at 0, but I want it to start at 70.

                使用上面的代码后是这样的:

                After using the above code, this is what it looks like:

                SeekBar 是最大数,EditText 也是最大数.

                The SeekBar is at the maximum number and the EditText is at the maximum as well.

                推荐答案

                etOne = (EditText) findViewById(R.id.etSyst);
                        etOne.addTextChangedListener(new TextWatcher() {
                            public void afterTextChanged(Editable s) {
                                int i = Integer.parseInt(s.toString());
                                if (i >= 70 && i <= 190) {
                                    sbSyst.setProgress( i - 70); // This ensures 0-120 value for seekbar
                                }
                            }
                            public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
                
                            public void onTextChanged(CharSequence s, int start, int before, int count) {}
                        });
                

                这篇关于根据 EditText 值更改 SeekBar 进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何使用 TextWatcher 更新相同的 EditText? 下一篇:如何更改editText字段上的突出显示颜色

                相关文章

                最新文章

                1. <tfoot id='mHgBQ'></tfoot>

                  <small id='mHgBQ'></small><noframes id='mHgBQ'>

                2. <i id='mHgBQ'><tr id='mHgBQ'><dt id='mHgBQ'><q id='mHgBQ'><span id='mHgBQ'><b id='mHgBQ'><form id='mHgBQ'><ins id='mHgBQ'></ins><ul id='mHgBQ'></ul><sub id='mHgBQ'></sub></form><legend id='mHgBQ'></legend><bdo id='mHgBQ'><pre id='mHgBQ'><center id='mHgBQ'></center></pre></bdo></b><th id='mHgBQ'></th></span></q></dt></tr></i><div id='mHgBQ'><tfoot id='mHgBQ'></tfoot><dl id='mHgBQ'><fieldset id='mHgBQ'></fieldset></dl></div>
                  1. <legend id='mHgBQ'><style id='mHgBQ'><dir id='mHgBQ'><q id='mHgBQ'></q></dir></style></legend>

                    • <bdo id='mHgBQ'></bdo><ul id='mHgBQ'></ul>