我遇到了一个问题,由于类 classcast 异常,我遇到了致命异常。我做了一些研究,发现了这个:
http://docs.oracle.com/javase/7/docs/api/java/lang/ClassCastException.html
然而,这是我第一次遇到这样的问题 - 我不确定如何解决它。
09-19 15:41:48.711: E/AndroidRuntime(430): FATAL EXCEPTION: main
09-19 15:41:48.711: E/AndroidRuntime(430): java.lang.ClassCastException: android.widget.TextView
09-19 15:41:48.711: E/AndroidRuntime(430): at com.project.example.ssettings.UpdateActivity$NetworkTask.setProgressImgView(UpdateActivity.java:365)
09-19 15:41:48.711: E/AndroidRuntime(430): at com.project.example.ssettings.UpdateActivity$NetworkTask.onProgressUpdate(UpdateActivity.java:352)
09-19 15:41:48.711: E/AndroidRuntime(430): at com.project.example.ssettings.UpdateActivity$NetworkTask.onProgressUpdate(UpdateActivity.java:1)
09-19 15:41:48.711: E/AndroidRuntime(430): at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:432)
09-19 15:41:48.711: E/AndroidRuntime(430): at android.os.Handler.dispatchMessage(Handler.java:99)
09-19 15:41:48.711: E/AndroidRuntime(430): at android.os.Looper.loop(Looper.java:123)
09-19 15:41:48.711: E/AndroidRuntime(430): at android.app.ActivityThread.main(ActivityThread.java:3683)
09-19 15:41:48.711: E/AndroidRuntime(430): at java.lang.reflect.Method.invokeNative(Native Method)
09-19 15:41:48.711: E/AndroidRuntime(430): at java.lang.reflect.Method.invoke(Method.java:507)
09-19 15:41:48.711: E/AndroidRuntime(430): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-19 15:41:48.711: E/AndroidRuntime(430): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-19 15:41:48.711: E/AndroidRuntime(430): at dalvik.system.NativeStart.main(Native Method)
代码:
@Override
protected void onProgressUpdate(Integer... progress) {
// Call function to update image view
setProgressImgView(progress[0], progress[1], progress[2],
progress[3], progress[4]);
}
private void setProgressImgView(Integer imgViewId1, Integer imgViewId2,
Integer imgViewId3, Integer imgViewId4, Integer imgViewId5) {
// update image view with the updating dots
// Reset view layout in case orientation while updating
setContentView(R.layout.updating);
mProgressImageview1 = (ImageView) findViewById(R.id.loading_empty1);
mProgressImageview2 = (ImageView) findViewById(R.id.loading_empty2);
mProgressImageview3 = (ImageView) findViewById(R.id.loading_empty3);
mProgressImageview4 = (ImageView) findViewById(R.id.loading_empty4);
mProgressImageview5 = (ImageView) findViewById(R.id.loading_empty5);
mProgressImageview1.setImageResource(imgViewId1);
mProgressImageview2.setImageResource(imgViewId2);
mProgressImageview3.setImageResource(imgViewId3);
mProgressImageview4.setImageResource(imgViewId4);
mProgressImageview5.setImageResource(imgViewId5);
}