Android(安卓)ContextThemeWrapper cannot be cast to android.app.Activity
16lz
2022-06-19
java.lang.ClassCastException: android.view.ContextThemeWrapper cannot be cast to android.app.Activity
Dialog中的context,在强制装换Activity出现。
将(Activity) mContext,变成:scanForActivity(mContext)
private static Activity scanForActivity(Context cont) { if (cont == null) return null; else if (cont instanceof Activity) return (Activity)cont; else if (cont instanceof ContextWrapper) return scanForActivity(((ContextWrapper)cont).getBaseContext()); return null;}
更多相关文章
- android 导入第三方库出现java.lang.NoClassDefFoundError
- android 修改系统显示u盘的名称
- android scrollview嵌套listview出现高度显示不全解决方案
- 更新android sdk出现 A folder failed to be renamed or moved
- Android(安卓)自定义Dialog时出现成员变量为null的问题
- Android(安卓)原生系统给电信发短信出现乱码或者收不到的原因
- Android源码下载出现的问题
- Android(安卓)Studio启动时出现unable to access android sdk ad
- 打开Android开发软件eclipse时出现parseSdkContent failed