android - 如何处理同一位置标记上的点击事件
问题描述
我正在使用标记视图来显示标记。
我的代码:
View customView = LayoutInflater.from(activity).inflate(R.layout.dialog_obstacle_with_markers, null);
customView.setLayoutParams(new FrameLayout.LayoutParams(WRAP_CONTENT, WRAP_CONTENT));
ImageView iv_marker = customView.findViewById(R.id.iv_marker);
iv_marker.setTag(reportItemArrayList.get(i).getReportId());
ImageView iv_marker_white = customView.findViewById(R.id.iv_marker_white);
FrameLayout fl_category = customView.findViewById(R.id.fl_category);
ImageView iv_obstacle = customView.findViewById(R.id.iv_obstacle);
TextView tv_obstacle = customView.findViewById(R.id.tv_obstacle);
int[] rgbValue = Utils.getRGBFromHex(reportItemArrayList.get(i).getColor());
iv_marker.setColorFilter(Color.rgb(rgbValue[0], rgbValue[1], rgbValue[2]));
Glide.with(activity)
.load(reportItemArrayList.get(i).getFilename())
.apply(new RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.ALL)
.placeholder(R.mipmap.ic_obstacle_place_holder)
.error(R.mipmap.ic_obstacle_place_holder))
.into(iv_obstacle);
tv_obstacle.setText(reportItemArrayList.get(i).getCategoryName());
MarkerView markerView = new MarkerView(new LatLng(Double.parseDouble(reportItemArrayList.get(i).getLat()), Double.parseDouble(reportItemArrayList.get(i).getLng())), customView);
markerViewManager.addMarker(markerView);
在这里,我有多个相同的位置标记可用,并且由于相同的位置,我只能看到第一个位置标记和其他标记在第一个标记后面。
现在我想处理第一个标记后面的其他标记的点击事件。
目前,由于位置相同,我只获得了第一个位置标记点击。
但我希望所有点击事件都在第一个标记后面。
请帮我解决一下这个。
解决方案
你不能像这样处理相同位置标记的点击事件。标记应该有不同的位置来处理它们。
推荐阅读
- python - 拆分字符串并附加到新列表
- python - 如何正确地从一些不同的列中提取数据?
- php - 它是 PHP 中嵌套 if 语句的一个很好的替代方案吗?
- python - 两个命令都给出“要求已经满足”
- javascript - 在动态组件中仅安装一次触发器
- node.js - 如何在节点 js public/uploads/image 中获取质量百分比的图像
- python - python中特定位置的截图
- git - Git 与子文件合并
- java - 如何解决我遇到的 Java 错误
- python - TensorFlow:如何在急切执行期间将 DeferredTensor 转换为 Tensor(以执行组规范化)?