【问题标题】:scroll edittext content on change of seek bar在搜索栏更改时滚动编辑文本内容
【发布时间】:2013-02-23 06:30:05
【问题描述】:

我搜索了很多,但找不到任何可以帮助我了解的东西 如何在更改搜索栏时滚动编辑文本内容 当前位置和进度。

请帮忙.....

public void startScrollingText() {

    timer = new Timer();

    System.out.println(CurrentValues.cur_script_speed
            + "its a current speed");
    script_speed = (int) (100 - CurrentValues.cur_script_speed);
    timer.schedule(new TimerTask() {

        @Override
        public void run() {
            MainActivity.this.runOnUiThread(new Runnable() {
                public void run() {
                    final Layout layout = script.getLayout(); // System.out.println(textview.getScrollY());
                    if (layout != null) {
                        int scrollDelta = layout.getLineBottom(script
                                .getLineCount() - 1)
                                - script.getScrollY()
                                - script.getHeight();
                        // System.out.println(scrollDelta);
                        if (scrollDelta > 0)
                            script.scrollTo(0, script.getScrollY() + 5);
                        // else
                        // script.scrollTo(0, 0);
                        System.out.println(CurrentValues.cur_script_speed
                                + " current speed");
                    }
                }
            });

        }

    }, 1000, script_speed + 1);
}

【问题讨论】:

  • 你确定你没有得到类似的东西吗??
  • 我刚刚知道了如何使用搜索栏监听器,我尝试了一整天,但它不能正常工作。当我更改搜索栏时,编辑框没有滚动
  • 看看下面的答案,希望对你有帮助。

标签: android android-layout android-widget android-edittext


【解决方案1】:

如果您已让 SeekBar 工作并初始化了 EditText,那么您必须知道这些值会随着下面的方法而改变。

这是你应该做的,

public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
               yourEditText.setText("changing values are "+progress);
            }

【讨论】:

  • 谢谢,但我需要滚动编辑文本内容...如果您知道如何滚动编辑文本,请提供帮助
  • 在 onprogresschanged 中调用上面的函数,正如我在上面显示的 stackoverflow.com/a/6124165/1503130 这可能会解决你的问题。但是你需要在上面的函数中做所有事情。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2021-05-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多