Can a GridView have a footer and header just like ListView?

前端 未结 11 2070
北海茫月
北海茫月 2020-12-14 16:29

A quick question:

In ListView I use this code:

list.addHeaderView(headerView);

How to deal with it when working on

11条回答
  •  情深已故
    2020-12-14 17:07

    How about checking for the "0" index element in your adapter? You can inflate the custom view for the first one.

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View view = convertView;
                if(view==null){
                     if(position==0){
                          //  ...inflate header view
                     }else{
                          //  ...do as usual
    

    Haven't tested it, but should work.

提交回复
热议问题