-2
我可能擁有自己的類「Torrent」,其中包含一些關於我在專用PC上的uTorrent下載的數據。每秒鐘在後臺更新ArrayList<Torrent> torrents
。 所以,我有一個像已知模式的RecyclerView.Adapter。 請給我解釋一下,爲什麼這代碼是可以正常使用:ViewHolder的onBindViewHoleder()方法的邏輯?
@Override
public void onBindViewHolder(final MyViewHolder holder,int position){
...
// Update ETA textView
holder.tvEta.setText(String.format(Locale.getDefault(),"%d h %d min %d s",torrents.get(position).getEta()/3600,(torrents.get(position).getEta()%3600)/60,torrents.get(position).getEta()%60));
...
}
但在這種情況下不工作?它只是更新的開始和不改變多個第一值:
@Override
public void onBindViewHolder(final MyViewHolder holder,int position){
...
// Update ETA textView
int secs = torrents.get(position).getEta();
int hours = secs/3600;
int minutes = (secs % 3600)/60;
int seconds = secs % 60;
holder.tvEta.setText(Locale.getDefault(), String.format("%d h %d min %d s", hours, minutes, seconds));
...
}
不工作如下圖所示
..仍然沒有改變... – rbaloo