当我尝试使用 setText 方法在 textView 上显示计时器时,它正在工作。但是这里的计时器(文本)没有得到任何更新,卡上只显示“0, 0, 0, 0”。我正在使用cardlib 库来显示卡片。我不知道是否可以在卡片上显示计时器。谁能帮我克服这个问题?
*这是我的代码:
long day, hour, min, sec;
MyCard card;
ArrayList<Card> cards = new ArrayList<Card>();
card = new MyCard(getActivity());
card.mainHeader= "Main Header";
card.mainTitle = "Main Title";
new CountDownTimer(86500000, 1000) { // adjust the milli seconds here
public void onTick(long millisUntilFinished) {
card.secondaryTitle = day + " day, " + hour + " hour, " + min + " minute, " + sec + " second";
day = TimeUnit.MILLISECONDS.toDays(millisUntilFinished);
hour = TimeUnit.MILLISECONDS.toHours(millisUntilFinished) - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(millisUntilFinished));
min = TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished) - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS.toHours(millisUntilFinished));
sec = TimeUnit.MILLISECONDS.toSeconds(millisUntilFinished) - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished));
}
public void onFinish() {card.secondaryTitle = ("done!");}
}.start();
card.resourceIdThumb = R.drawable.ic_school_black_48dp;
CardHeader header = new CardHeader(getActivity());
header.setTitle(card.mainHeader);
//Add Header to card
card.addCardHeader(header);
//Add the thumbnail
CardThumbnail thumb = new CardThumbnail(getActivity());
thumb.setDrawableResource(card.resourceIdThumb);
card.addCardThumbnail(thumb);
card.setOnClickListener(listener);
cards.add(card);
抱歉,由于我的声誉,我无法上传图片。这是我的卡片图片的链接: