我如何在每个新的一天为变量DOW增加1?
所以它会是:
monday dow = 1;
tuesday dow = 2;
wednesday dow =3
thursday dow =4;
friday dow =5;
saturday dow =6;
sunday down 7;
monday dow=8;
它不会重置,直到它达到365,然后一旦我有了这个变量,我可以在这里使用它;
int dow = 0;
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
counter++;
if (counter >= list.length)
counter = 0;
quote.setText(list [dow]);
}
答案 0 :(得分:0)
Calendar calendar = Calendar.getInstance();
int doy = calendar.get(Calendar.DAY_OF_YEAR);
// int doy gives me the result 174 which is the day of year so it sets the quote text to string array number 174.
@Override
public void onClick(View v) {
title.setText("Quote of the day:");
quote.setText(list [doy]);
}