开发者

Android: Cannot cast from View to Chronometer

I try to follow this example ChronometerDemo.java, but I got some problem:

  1. I can't import android.widget.Chronometer; Error: conflicts with a type defined in a same file(import android.widget.Chronometer.OnChronometer开发者_运维知识库TickListener)
  2. I can't cast View to Chronometer mChronometer = (Chronometer) findViewById(R.id.chronometer);

Anyone can help? Appreciate, Daisy


There seems to be another Chronometer class present that does not extend from View, which is why you can't cast it. It's hard to tell without your code, but did you rename ChronometerDemo.java to Chronometer.java? ChronometerDemo is an Activity, and is not supposed to be returned by a findViewById call.

This is, of course, assuming you're talking about this.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜