我有一个带有以下代码的适配器:
@Override
public View getView(int pos, View contentView, ViewGroup arg2) {
final Trip route = (Trip)getItem(pos);
if(contentView == null){
LayoutInflater inflater = (LayoutInflater)mContext.getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
contentView = inflater.inflate(R.layout.route_list_item_complete, null);
holder = new Holder();
holder.textViewFrom = (TextView)contentView.findViewById(R.id.tv_routeitem_address_from);
contentView.setTag(holder);
}else{
holder = (Holder)contentView.getTag();
}
if(getDate(calendarTimestamp).equalsIgnoreCase(mContext.getResources().getString(R.string.today))){
countDownTimer = new CountDownTimer(horaAcumulada, 500) {
@Override
public void onTick(long leftTimeInMilliseconds) {
long secondsInMilli = 1000;
long minutesInMilli = secondsInMilli * 60;
long hoursInMilli = minutesInMilli * 60;
long daysInMilli = hoursInMilli * 24;
leftTimeInMilliseconds = leftTimeInMilliseconds % daysInMilli;
long elapsedHours = leftTimeInMilliseconds / hoursInMilli;
leftTimeInMilliseconds = leftTimeInMilliseconds % hoursInMilli;
long elapsedMinutes = leftTimeInMilliseconds / minutesInMilli;
leftTimeInMilliseconds = leftTimeInMilliseconds % minutesInMilli;
long elapsedSeconds = leftTimeInMilliseconds / secondsInMilli;
if(String.format("%02d", elapsedHours).equals("00")){
holder.textViewFrom.setText(String.format("%02d", elapsedMinutes)+ ":" + String.format("%02d", elapsedSeconds) + " MIN");
}else{
holder.textViewFrom.setText(String.format("%02d", elapsedHours) + "H " + String.format("%02d", elapsedMinutes) + ":" + String.format("%02d", elapsedSeconds) + " MIN");
}
}
@Override
public void onFinish() {
}
}.start();
}else{
holder.textViewFrom.setText(DateFormat.format("hh:mm aa", date));
}
}
我对TextView“textViewFrom”有以下行为。当它进入并使用“countDownTimer”时,它总是得到“textViewFrom”的最后一个并更新它。我的意思是,如果需要在4个视图列表中更新的唯一一个是数字2,它会不断更新最后一个。
感谢您提供给我的所有信息。