在我的应用程序中,我正在显示数据库中的自定义列表。选择几行列表后,我想从Listview和数据库中删除这些行。怎么办?
答案 0 :(得分:0)
如果您的ListView
数据保存在List
中,请在List
中的项目模型中添加一个变量,以标记所选项目。单击删除按钮后,循环浏览List
并从List
中删除所选项目,并将其从DB中删除。循环后调用Adapter.notifyDatasetChange()
。
答案 1 :(得分:0)
所以你应该像下面那样包装你的项目:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="dashboard-info list-requests request-negotiating" >
<div class="enquiry request-item request-negotiating-item" >1</div>
<div class="enquiry request-item request-negotiating-item" >2</div>
<div class="enquiry request-item request-negotiating-item" style="display: none;">3</div>
<div class="enquiry request-item request-negotiating-item" style="display: none;">4</div>
<div class="enquiry request-item request-negotiating-item" style="display: none;">5</div>
<div class="enquiry request-item request-negotiating-item" style="display: none;">6</div>
<div class="enquiry request-item request-negotiating-item" style="display: none;">7</div>
<div class="enquiry request-item request-negotiating-item" style="display: none;">8</div>
<div class="enquiry request-item request-negotiating-item" style="display: none;">9</div>
<div class="enquiry request-item request-negotiating-item" style="display: none;">10</div>
<div class="enquiry request-item request-negotiating-item" style="display: none;">11</div>
<div class="enquiry request-item request-negotiating-item" style="display: none;">12</div>
</div>
<div class="dashboard-title list-request-negotiating-loadmore loadmore" style="">load more</div>
然后你可以使用position来获取Item并将public class Item {
private HashMap<String, String> content;
private boolean isSelected;
public HashMap<String, String> getContent() {
return content;
}
public void setContent(HashMap<String, String> content) {
this.content = content;
}
public boolean isSelected() {
return isSelected;
}
public void setSelected(boolean selected) {
isSelected = selected;
}
}
设置为true或false。并将isSelected
更改为List<HashMap<String, String>>