gpt4 book ai didi

java - androidx.gridlayout.widget.GridLayout 无法转换为 android.widget.GridLayout

转载 作者:行者123 更新时间:2023-12-04 12:07:32 26 4
gpt4 key购买 nike

我收到错误

"Caused by: java.lang.ClassCastException: androidx.gridlayout.widget.GridLayout cannot be cast to android.widget.GridLayout", in mainActivity.java


 GridLayout mygridLayout = findViewById(R.id.gridLayout);

for(int i=0; i<mygridLayout.getChildCount(); i++)
{
((ImageView) mygridLayout.getChildAt(i)).setImageResource(0);
}

最佳答案

改变

import android.widget.gridLayout 


import androidx.gridlayout.widget.GridLayout;

你的代码会起作用

关于java - androidx.gridlayout.widget.GridLayout 无法转换为 android.widget.GridLayout,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59195798/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com