我正在编写周期表软件,一节是化学公式列表。该应用程序允许用户从列表中搜索 但我在过滤结果时遇到了一些麻烦
FurmulaProvider.java
<form id="myForm">
<button value="1">Submit 1</button>
<button value="2">Submit 2</button>
<button value="3">Submit 3</button>
</form>
<script>
$f = $("#myForm");
$f.find("button[type=submit]").on("click", remember_button);
$f.on("submit", on_submit_click);
function remember_button() {
var val = $(this).val();
var $remembered_button = $f.find(".remembered_button");
if (!$remembered_button.length) {
$remembered_button = $("<input>")
.attr("type", "hidden")
.attr("name", "button_value")
.addClass("remembered_button")
.appendTo($f);
}
$remembered_button.val(val);
}
on_submit_click(event) {
event.preventDefault();
var val = $f.find(".remembered_button").val();
$f.submit();
}
</script>
自定义适配器是:
public class FurmolaProvider {
private int id;
private String sympol;
private String name;
public FurmolaProvider(int id, String sym, String name) {
this.setId(id);
this.setName(name);
this.setSympol(sym);
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getSympol() {
return sympol;
}
public void setSympol(String sympol) {
this.sympol = sympol;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}
注意:disp_ls包含所有元素
,
当我运行此代码时,没有任何反应。你能帮我吗 ?! :)
答案 0 :(得分:0)
您必须返回您创建的过滤器
return filter;
而不是
return super.getFilter();