cannot be cast to android.app.Activity
zhugscn opened this issue · comments
Caused by: java.lang.ClassCastException: android.app.Presentation$3 cannot be cast to android.app.Activity
at anylife.scrolltextview.ScrollTextView.(ScrollTextView.java:103)
at java.lang.reflect.Constructor.newInstance0(Native Method)
原因分析:可能我用的是AppCompatActivity,而此库写死为Activity强制转换,出现错误
DisplayMetrics metric = new DisplayMetrics();
((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(metric);
density = metric.density;
@zhugscn 请先升级到1.4.5 ,如果还有问题可以的话给我一个关于 ava.lang.ClassCastException: android.app.Presentation$3 cannot be cast to android.app.Activity 的Demo