我有一个列表视图,其中的项目有一个文本视图和一个按钮。我已成功地使列表视图的onclick和按钮上点击共同努力。现在的问题是,当我按一下按钮我真的不知道视图项指数它属于什么表了。有没有什么办法可以知道吗?我需要这个将它传递给一个CRUD进行编辑,等等...
I have a list view where items have a text view and a button. I have managed to make list view onclick and button on click work together. The problem is that when I click the button I don't really know what list view item index it belongs too. Is there any way to know that? I need this to pass it to a "CRUD" for editing, etc...
您可以使用setTag和getTag这里获得点击的ListView控件按钮的位置,
You can use setTag and getTag here to get the position of the Button Clicked in the ListView,
喜欢的东西,
button.setTag(位置);
//你的getView()方法
button.setTag(position);
// in your getView() method
然后
INT CUR_POS =(整数)v.getTag();
//内巴顿的onClick在getView()方法
int cur_pos = (Integer)v.getTag();
// inside onClick of Button in getView() method