确定2D阵列中ImageView的位置

时间:2022-04-01 01:45:20

Is there a way to find the location of a specific imageView given an ID in a 2D array? For example if I have ImageView [x][y] and each of the ImageViews has an ID, is it possible to find the specific [x][y] of an Image given that I know the ID of the ImageView I'm looking for?

有没有办法在2D数组中找到给定ID的特定imageView的位置?例如,如果我有ImageView [x] [y]并且每个ImageView都有一个ID,是否可以找到图像的特定[x] [y],因为我知道我正在寻找的ImageView的ID对于?

1 个解决方案

#1


0  

You'd have to iterate through and testing each ImageView using getId().

您必须使用getId()迭代并测试每个ImageView。

If performance is a problem then you could build an index using HashMap with keys as ids and values as (x, y) pairs.

如果性能是一个问题,那么您可以使用HashMap构建索引,其中键为id,值为(x,y)对。

#1


0  

You'd have to iterate through and testing each ImageView using getId().

您必须使用getId()迭代并测试每个ImageView。

If performance is a problem then you could build an index using HashMap with keys as ids and values as (x, y) pairs.

如果性能是一个问题,那么您可以使用HashMap构建索引,其中键为id,值为(x,y)对。