cursoradapter with different row layouts

后端 未结 3 1706
心在旅途
心在旅途 2020-12-02 08:08

I\'m trying to create a custom cursoradapter that will use two different layouts depending on some data in the cursor. I keep reading about \'overriding getViewTypeCount() a

3条回答
  •  心在旅途
    2020-12-02 08:25

    Another possible solution regarding the access to the cursor in the getItemViewType method is the following:

    @Override
    public int getChildType(int groupPosition, int childPosition) {
        Cursor c = getChild(groupPosition, childPosition);
        if(c.getString(c.getColumnIndex(Contract.MyColumn)).equals("value"))
            return 0;
        else return 1;
    }
    

提交回复
热议问题