进度条不动
我的列表视图中的每个项目都有进度条。当我点击列表中的某个项目时,另一个线程会使进度条移动。由于某种原因,输出显示进度条正在增加,但事实并非如此。下面是一些代码。
mHandler.post(new Runnable() {
public void run() {
ViewHolder vh = (ViewHolder) adapter.getView(pro, null, null).getTag();
Log.d("Progress",String.valueOf(vh.progress.getProgress()));
vh.progress.setProgress((int) prog[pro]);
}
});
I have progress bar in every item inside my listview. When I tap an item on the list, another thread makes the progress bar move. For some reason the output says the progress bar is increasing but it's not. Below is some of the code.
mHandler.post(new Runnable() {
public void run() {
ViewHolder vh = (ViewHolder) adapter.getView(pro, null, null).getTag();
Log.d("Progress",String.valueOf(vh.progress.getProgress()));
vh.progress.setProgress((int) prog[pro]);
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Adapter
上的getView()
可能会创建一个全新的行,因为这就是您调用getView()
时应该执行的操作第二个参数为null
。您需要有一个更好的方案来检索要更新的
ProgressBar
,同时考虑到ProgressBar
可能已被回收以显示其他行的进度。getView()
on yourAdapter
is probably creating a brand new row, since that's what it is supposed to do when you callgetView()
with anull
second parameter.You need to have a better scheme for retrieving the
ProgressBar
that you wish to update, taking into account that theProgressBar
may have been recycled to be displaying some other row's progress.