xpandableListView的getChildView在安

xpandableListView的getChildView在安

本文介绍了如何识别按钮单击ExpandableListView的getChildView在安卓的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立ExpandableListView在我的Andr​​oid应用程序。我做了孩子的XML布局,重复高达具体的数字。我有一个删除按钮在我与XML作为btnDelete ID组XML布局。点击删除按钮,我想删除特定的孩子。

I am building ExpandableListView in my android app. I have made child xml layout that repeats upto specific numbers. I have a Delete Button in my xml layout with id set in xml as btnDelete. By clicking delete button I want to delete specific child.

例如:

组:

Child 1         Delete
Child 2         Delete
Chile 3         Delete

现在我的问题是,如何确定点击哪个孩子删除按钮。由于所有的删除按钮,在我的XML布局相同的ID。请给我建议的解决方案。

Now my problem is that how to identify that which child delete button is clicked. As all delete buttons have same ID in my xml layout. Please suggest me a solution.

推荐答案

在您的适配器,在那里你吹你的排布置,可以设置一个标记(与 setTag()法)为每个删除按钮。该标签可以是该行的位置,这个删除按钮对应。

In your adapter, where you inflate your row layout, you can set a tag (with the setTag () method) to each delete button. The tag can be the row position that this delete button corresponds to.

后来,当有人点击该按钮,在 onClickListener ,你得到的按钮标记(与 v.getTag()),解析为整数,并删除该行的那个位置。

Later, when someone clicks the button, in the onClickListener, you get the button tag (with v.getTag ()), parse it to integer and delete the row at that position.

这篇关于如何识别按钮单击ExpandableListView的getChildView在安卓的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-02 23:20