android-studio - ClasscastException 无法转换为线性布局或 Button.widget.button
问题描述
Process: com.example.e_classroom, PID: 12427
java.lang.ClassCastException: android.widget.LinearLayout cannot be cast to android.widget.Button
at com.example.e_classroom.test_questions$3.onAnimationEnd(test_questions.java:116)
at android.view.ViewPropertyAnimator$AnimatorEventListener.onAnimationEnd(ViewPropertyAnimator.java:1136)
at android.animation.ValueAnimator.endAnimation(ValueAnimator.java:1171)
at android.animation.ValueAnimator$AnimationHandler.doAnimationFrame(ValueAnimator.java:722)
at android.animation.ValueAnimator$AnimationHandler.run(ValueAnimator.java:738)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:800)
at android.view.Choreographer.doCallbacks(Choreographer.java:603)
at android.view.Choreographer.doFrame(Choreographer.java:571)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:786)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5637)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:960)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
这里发现错误任何人都可以帮助这个如何解决这个错误
public void onAnimationEnd(Animator animation) {
if(value==0) {
try{
((TextView)v).setText(data);
questindicator.setText(position+1+"/"+list.size());
}catch (ClassCastException ex){
// here 116 line no
((Button)v).setText(data);
}
v.setTag(data);
playanimate(v, 1,data);
}
}
解决方案
推荐阅读
- reactjs - componentDidMount 和 componentWillUnmount 是如何工作的?
- java - 如何将不同驱动器中的 jar 包含到 jar 文件中的清单文件中
- javascript - 基本 js 对象数组引用
- flutter - 我在 HomePage 类中调用 FirstPage 但它没有显示任何内容?
- sql - 使用没有命名目录的 dbms_xmldom.writetofile
- python - 3 Python 3 中的求和问题,Leetcode 中超过了时间限制
- c# - string.IsNullOrEmpty() 不是扩展方法有什么特别的原因吗?
- firebase - Firebase 搜索查询返回空结果
- typescript - TypeScript:从某种类型创建一个联合类型的字符串
- python - 基于 QSqlTableModel 编辑新记录的 QTableView 不会在 PyQt 中保存编辑