美好的一天,请建立一个足球预测应用程序,我想显示比赛时间的倒计时。一旦游戏开始,我打电话给另一个功能,但我不能正确倒计时。倒计时计时器android
这里是曾尝试:
public void onSuccess(String response) {
try {
JSONObject json = new JSONObject(response);
userid.setText("Welcome: "+ usermail);
hometeam.setText(json.getString("Home_Team"));
awayteam.setText(json.getString("Away_Team"));
home_logo.setImageUrl(url+json.getString("Home_Logo"));
away_logo.setImageUrl(url+json.getString("Away_Logo"));
game_id.setText(json.getString("ID"));
match_date.setText(json.getString("Date")+" "+json.getString("Time"));
//month.setText(json.getInt(name))
SimpleDateFormat mdate = new SimpleDateFormat("yyyy-MM-dd");
Date m_date= (Date) match_date.getText();
CountDownTimer cdt = new CountDownTimer(m_date.getTime(), 1000) {
public void onTick(long millisUntilFinished) {
// TODO Auto-generated method stub
Log.d("tick","clocks ticks");
}
public void onFinish() {
// TODO Auto-generated method stub
}
}.start();
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
但是,一旦我运行应用程序,它崩溃。它工作正常,直到我添加倒计时功能。日期和时间以这种格式返回。 "2013-12-23 20:00:00"
。谢谢。
可以请一个logcat的添加到您的答案 –
HII的logcat的说java.lang.String中不能转换为Java。 util.date。猜测从数据库中检索日期和时间的行。谢谢 – altoin
不要猜测,它给出了什么行号,那行是什么?为什么有mdate和m_date?为什么要调用getText()? logcat是你的指南,明确地告诉你想要错误。我们需要它以及突出显示的特定代码行! – RossC