0

我正在尝试从 gridview 中的每个选定项目中读取这些 uri,然后将它们存储在 Uri 数组中并从那里读取它们。

这是我的代码:

for (int i = 0; i < imagegrid.getChildCount(); i++) {
                Uri uri = (Uri) imageAdapter.getItem(i);
                View view = imagegrid.getChildAt(i);
                CheckBox checkBox = (CheckBox) view.findViewById(R.id.itemCheckBox);
                // ImageView iv = (ImageView) view.findViewById(R.id.image);

                if (checkBox.isChecked())
                {
                    editImagesUri[count] = uri;
                }
            }

在我运行之前,我没有错误,但是当我这样做时,我得到“Integer cannot be cast to Uri”。我正在使用的这种方法有什么替代品吗?我将不胜感激任何帮助。

提前谢谢你!

4

1 回答 1

1

您的 getItem 函数没有返回 URI,而是返回一个 int。要么将其更改为返回 URI,要么在某处有一个 int->URI 映射。

于 2013-01-13T02:49:58.600 回答