当我运行此代码时,我的代码是这样的,我正面临异常
getMenuInflater().inflate(R.menu.admin__home, menu);
MenuItem item = menu.findItem(R.id.action_notifications);
LayerDrawable icon = (LayerDrawable) item.getIcon();
答案 0 :(得分:1)
android.support.graphics.drawable.VectorDrawableCompat无法强制转换为android.graphics.drawable.LayerDrawable
更改此
LayerDrawable icon = (LayerDrawable) item.getIcon();
到此
Drawable icon = (Drawable) item.getIcon();