我遇到错误
“由:java.lang.ClassCastException:
androidx.gridlayout.widget.GridLayout无法转换为
android.widget.GridLayout”,在mainActivity.java中
GridLayout mygridLayout = findViewById(R.id.gridLayout);
for(int i=0; i<mygridLayout.getChildCount(); i++)
{
((ImageView) mygridLayout.getChildAt(i)).setImageResource(0);
}
最佳答案
在代码中使用它会起作用。
androidx.gridlayout.widget.GridLayout mygridLayout = findViewById(R.id.gridLayout);
for(int i=0; i<mygridLayout.getChildCount(); i++){
((ImageView) mygridLayout.getChildAt(i)).setImageResource(0);
}