删除android中的动态表行
在我的应用程序中,我在每个表行中动态创建了表行
,我提供了一个图标来帮助用户帮助删除该特定行,
我该如何实现这一点?有什么建议吗,
有比使用 setVisibility()
更好的选择吗?
我尝试了 setTag()
和 setId()
,但删除一行后似乎不起作用,因为删除后 id 值保持不变
希望我的问题是很好理解
in my app, i have created table rows dynamically
in each table row, i provide an icon that will help the user help in deleting that specific row
how can i achieve this? any suggestions please
is there a better option than using setVisibility()
?
i tried setTag()
and setId()
, but it doesn't seem to work after one row is deleted, since the id values remain same after deletion
hope my question is well understood
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
让我们假设你的布局是这样的。
您的图标视图可以是任何 ImageView 或 ImageButton。因为你没有发布任何xml。我只是指图标。
现在,如何访问要删除的表行?
在 onClick 事件上。您可以访问图标视图。
将授予对父视图的访问权限,之后您可以对此视图执行删除操作。
lets assume your layout is like this.
your icon view can be anything ImageView or ImageButton. since you din't post any xml. i am just referring as icon.
Now, how to access the table row to delete?
on the onClick event. you get access to the icon view.
will give access to the parent view after which you can perform deletions on this view.