android简单游标适配器

时间:2012-12-18 12:52:31

标签: android simplecursoradapter

我有一个带有SimpleCursorAdapter的列表,这个列表是用arraylist制作的,问题是我想在列表中只添加具有“persoane.proprietar ==”no“的数组的值,这是我的代码详细信息

    private class ImageAndTextAdapter extends SimpleCursorAdapter {
    private Context adContext;

    public int getCount() {
        persNu = persPropNu();
        return persNu;
    }

    public ImageAndTextAdapter(Context context, int layout, Cursor c,
            String[] from, int[] to) {
        super(context, layout, c, from, to);
        this.adContext = context;
    }

    public View getView(int pos, View inView, ViewGroup parent) {
        View v = inView;
        if (v == null) {
            LayoutInflater inflater = (LayoutInflater) adContext
                    .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            v = inflater.inflate(R.layout.element_lista_items, null);
        }
 if (GetObiecte.persoane.get(pos).proprietar.equals("no"))//if put this line in the list will be a blank line if the propriety isn't no,and I don't need it
        ((TextView) v.findViewById(R.id.textListTopElem)).setText(GetObiecte.persoane.get (pos).nume);
        ((TextView) v.findViewById(R.id.textListElem)).setText(GetObiecte.persoane.get (pos).judet);
        if (GetObiecte.persoane.get(pos).tipPersoana.equals("fizica")){((ImageView) v.findViewById(R.id.imgListElem)).setImageResource(R.drawable.icon_foto_person);}
        else {((ImageView) v.findViewById(R.id.imgListElem)).setImageResource(R.drawable.icon_foto_person_pj);}
        return v;
    }
}

1 个答案:

答案 0 :(得分:0)

如果此值未动态更改,则仅将相关项发送给适配器。

如果动态更改,您可以使用解释为in this question

的过滤器