Why is Android recycling the wrong view type in my SpinnerAdapter?

后端 未结 2 2238
被撕碎了的回忆
被撕碎了的回忆 2021-02-15 19:18

I\'m trying to make an ActionBar spinner that has separators. I have implemented a SpinnerAdapter that has 2 item view types (thanks to getViewTypeCount

2条回答
  •  离开以前
    2021-02-15 19:48

    The problem is here:

    public View getView(final int position, final View convertView, final ViewGroup parent) {
        return getView(mActionBarItemLayoutResId, position, convertView, parent);
    }
    

    This method will always return the same View type, whether called for a separator or a data item. You need to check the position here and return an appropriate view.

提交回复
热议问题