使用自定义对象过滤自定义适配器/列表视图

时间:2016-12-10 19:59:28

标签: android listview filter adapter

我有使用它的自定义对象和适配器。我想使用filter for adapter,但默认实现不起作用。如何在适配器中设置自定义过滤器?

public class CustomObject {

public String variable1;
public String variable2;
public String variable3;

public CustomObject(String variable1, String variable2, String variable3) {
    super();

    this.variable1 = variable1;
    this.variable2 = variable2;
    this.variable3 = variable3;
    }
}

在Activity中我有适配器:

CustomObject data[] = new CustomObject [size];
AdapterContact adapter = new AdapterContact(context, R.layout.row, data);
ListView lv = (ListView) view.findViewById(R.id.lv);
lv.setAdapter(adapter);
adapter.getFilter().filter("keyword");

0 个答案:

没有答案