获得点击查看从onItemClickListener [英] Get clicked view from onItemClickListener

查看:260
本文介绍了获得点击查看从onItemClickListener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在设计一个游戏商店和我面临的一个问题与项目列表买:

I am currently designing a store for a game and am facing a problem with the list of items to buy:

我有一个的的ListView 的包含的 RelativeLayouts 的的项目 - 在每个 RelativeLayout的的两个内部的 RelativeLayouts 的,与在他们的项目。

I have a ListView containing RelativeLayouts as items - in each RelativeLayout are two inner RelativeLayouts, with the items in them.

我想找出是否在用户点击的购买的在ITEM1的ITEM2 - 但是我发现没有办法在的 onItemClickListener 的得到这个。
问题是,如果我使用的 onClickListener 的而不是 onItemClickListener 的,我有项目(一,二),而不是行 - 所以我总是要么该行或柱。

I want to find out if the user clicks on BUY in item1 or item2 - but I found no way to get this in an onItemClickListener. The problem is, if I use onClickListener instead of onItemClickListener, I have the item (one or two), but not the row - so I always have either the row or the column.

基本上,我需要从中获取实际点击项目的ID的 onItemClickedListener 的范围内 - ?有什么办法,我可以做到这一点。

Basically, I need to get the ID of the actually clicked Item from within the onItemClickedListener - is there any way I can do this?

推荐答案

在Adapter's的 getView()的一个标签添加到您的按钮(button.setTag(位置)),然后在onClickListener调用view.getTag()以检索索引

Add a Tag to your Button (button.setTag(position)) in the Adapter´s getView() and then in onClickListener call view.getTag() to retrive an index

这篇关于获得点击查看从onItemClickListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆