BaseAdapter自定义筛选器故障

时间:2013-05-05 22:28:57

标签: java android

您好我试图为我的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;
}

}

1 个答案:

答案 0 :(得分:0)

我在Custom Filter中使用了MultiSelectionList。这是Code

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

感谢。