且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ListView不“刷新";从中删除项目后

更新时间:2023-12-03 13:15:40

感谢所有帮助人员,但最终我得出的答案与您的答案完全不同.我最终使用了他的方法[1]: http://jmsliu.com/2444/click-button-in-listview-and-get-item-position.html/此处"对我来说绝对完美.无论如何,这是对那些可能遇到相同问题的人的帮助.

Thanks for all the help guys, but in the end the answer I came up with is quite different from yours. I ended up using his method [1]: http://jmsliu.com/2444/click-button-in-listview-and-get-item-position.html/ "here" which worked absolutely perfect for me. Anyways this was what did for those who might run into the same issue.

将此代码粘贴到位于.JAVA文件中的GetView()方法中,将XML文件插入.

Button deleteButton = (Button) customView.findViewById(R.id.deleteButton);
deleteButton.setTag(position);

然后将其添加到您的按钮点击监听器/onClick方法中

    int position = (Integer) view.getTag();
    list.remove(position);

    adapter.notifyDataSetChanged();