问题描述
我有一个ListView包含3个列表项,每个项目中都有进度条 单击的每个列表项都将启动一个 Intent Service ,该服务会下载文件并在进度栏中显示进度。下面是我的代码
@Override
protected void onHandleIntent(Intent intent) {
int progress = (int) ((total * 100) / fileSize);
Download download = new Download();
download.setProgress(progress );
}
private void sendIntent(Download download){
Intent intent = new Intent(ManageContentActivity.MESSAGE_PROGRESS);
intent.putExtra("download",download);
LocalbroadcastManager.getInstance(DownloadService.this).sendbroadcast(intent);
}
在我的活动中,我正在使用broadcastReciever更新我的列表视图项
private broadcastReceiver broadcastReceiver = new broadcastReceiver() {
@Override
public void onReceive(Context context,Intent intent) {
if(intent.getAction().equals(MESSAGE_PROGRESS)){
Download download = intent.getParcelableExtra("download");
View view = itemsListView.getChildAt(download.getItem_index());
if (view != null) {
progressBar = view.findViewById(R.id.tv);
if (progressBar != null) {
progressBar.setProgress(download.getProgress(),true);
Log.d("Progress",""+download.getProgress());
}
}
}
}
};
在尝试显示第二个列表项的进度时,我在这里遇到问题。它达到96%,然后更新了第一个列表项的进度条。我不确定这里发生了什么。任何帮助将不胜感激。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)