android.support.graphics.drawable.VectorDrawableCompat无法强制转换为android.graphics.drawable.LayerDrawable

时间:2017-10-13 13:31:43

标签: java android android-support-library

当我运行此代码时,我的代码是这样的,我正面临异常

getMenuInflater().inflate(R.menu.admin__home, menu);
MenuItem item = menu.findItem(R.id.action_notifications);
LayerDrawable icon = (LayerDrawable) item.getIcon();

1 个答案:

答案 0 :(得分:1)

  

android.support.graphics.drawable.VectorDrawableCompat无法强制转换为android.graphics.drawable.LayerDrawable

更改此

LayerDrawable icon = (LayerDrawable) item.getIcon();

到此

Drawable icon = (Drawable) item.getIcon();