0

嗨,我正在尝试CustomFilter为我创建一个BaseAdapter,但运气不佳.. 我在数据库中查询 ID、姓名和性别的数组。在listview我希望搜索我已经实现的列表textview并且对代码没有运气。这是我的CustomAdapter

public class MyCustomBaseAdapter extends BaseAdapter {
private static ArrayList<Custom> AList;

private LayoutInflater inflat;

public MyCustomBaseAdapter(Context context, ArrayList<Custom> results) {
    AList = results;
    inflat = LayoutInflater.from(context);
}

public int getCount() {
    return AList.size();
}

public Object getItem(int position) {
    return AList.get(position);
}

public long getItemId(int position) {
    Long.parseLong(AList.get(position).getID());
    return position;
}

public View getView(int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
        convertView = inflat.inflate(R.layout.suspect_list, null);
        holder = new ViewHolder();
        holder.txtName = (TextView) convertView.findViewById(R.id.suspect_name);
        holder.txtSex = (TextView) convertView.findViewById(R.id.suspect_sex);
        holder.txtId = (TextView) convertView.findViewById(R.id.suspect_id);

        convertView.setTag(holder);
    } else {
        holder = (ViewHolder) convertView.getTag();
    }

    holder.txtName.setText(AList.get(position).getName());
    holder.txtSex.setText(AList.get(position).getSex());
    holder.txtId.setText(AList.get(position).getID());

    return convertView;
}

static class ViewHolder {
    TextView txtName;
    TextView txtSex;
    TextView txtId;
}

}

4

1 回答 1

0

我用Custom FilterMultiSelectionList. 这是代码

请下载演示,运行并尝试了解并根据您的需要使用该代码,并根据您的要求进行修改。

谢谢。

于 2013-05-06T04:02:48.863 回答