Android的搜索栏后动态设置最大值与SETMAX不会刷新 [英] Android SeekBar doesn't refresh after dynamically setting max value with setMax

查看:145
本文介绍了Android的搜索栏后动态设置最大值与SETMAX不会刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是股票SeekBar组件通过一组ViewPagers的导航和它的工作相当精细。唯一的问题是,当数据的变化,我不得不通过SETMAX(int值),动态改变搜索栏的最大值。当我这样做,搜索栏没有更新,直到我浏览到一个新的一页。我在的地方,我做这哈克修复,强制onProgressChanged:

I am using the stock SeekBar component to navigate through a set of ViewPagers and it's working quite fine. Only problem is that when the data changes, I have to dynamically change the max value of the SeekBar via setMax(int value). When I do that, the SeekBar does not get updated until I navigate to a new page. I have a hacky fix in place where I do this, to force a onProgressChanged:

seekBarVP.setProgress(focusedPage+1);
seekBarVP.setProgress(focusedPage-1);
seekBarVP.setProgress(focusedPage);

有没有更好的方法来做到这一点?

Is there a better way to do this?

推荐答案

现在的问题是一些个月大,但现在因为寻找这个问题把我带到这里,我会回答反正

The Question is some months old now but I'll answer anyway because searching for this problem brought me here.

答案是居然还有Android中的错误。这似乎是固定在我的平板电脑3.2.1,但这个错误是我的手机2.3.6 present。该缺陷是在进度控件,它是搜索栏类的父。您的解决方案的进展情况设置一个虚假的价值和背部是迄今为止easies解决办法,我能找到。

Answer is there is actually a bug in Android. It seems to be fixed on my 3.2.1 tablet but the bug is present on my 2.3.6 phone. The bug is in the ProgressBar widget which is a parent of the SeekBar class. Your solution to setting the progress to a bogus value and back is so far the easies workaround I could find.

您会发现这里这个错误的详细信息:
<一href=\"http://stackoverflow.com/questions/4348032/android-progressbar-does-not-update-progress-view-drawable\">android进度不更新发展观/绘

You will find more detailed information about this bug here: android progressBar does not update progress view/drawable

这篇关于Android的搜索栏后动态设置最大值与SETMAX不会刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆