2

嗨,我在更新进度条时遇到问题。

首先,我有一个自定义适配器,在其中我为每个项目创建一行,其中包含一个文本视图和一个进度条。(我有一个 item_row.xml 在其中定义每一行的布局)

public View getView(int position, View convertView, ViewGroup parent) { 
.....
     ProgressBar progressHorizontal = (ProgressBar)tripListItemView.findViewById(R.id.downloadprogress);
        if (offline) {
            progressHorizontal.setVisibility(View.VISIBLE);
            progressHorizontal.setProgress(t.getDownloaded());
        } else
            progressHorizontal.setVisibility(View.INVISIBLE);

        TextView itemName  =(TextView)tripListItemView.findViewById(R.id.tripsname);

好的,现在我有一个从外部 API 下载后台数据的服务,我想何时随着下载进度每秒更新进度条。

为此,我有一个使用处理程序(参考)制作的计时器任务

但问题是如何再次访问在我的适配器中创建的进度条以更新进度?

谢谢

4

1 回答 1

1

这应该很容易;)

ProgressBar pb = (ProgressBar)((View)list.getChildAt(i)).findViewById(R.id. downloadprogress);
于 2010-02-27T16:25:28.507 回答