Android adding footer to ListView addFooterView()?

后端 未结 3 1403
时光取名叫无心
时光取名叫无心 2020-12-10 04:08

I have a ListView activity that needs a footer to the list of items so that you can click it and it would load more items into the list. The list is backed my an SimpleAdapt

3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-10 04:42

    Alrighty Iv found a solution to my problem if i do this it works as intended:

    View view = mInflater.inflate(R.layout.list_load_more_row, null);
    
    TextView footer = (TextView) view.findViewById(R.id.loadMore);
    
    getListView().addFooterView(footer);
    
    setListAdapter(ListViewHelper.getAdapterForContentList(mContent, this));
    

    I'm guessing that since I put null in the inflater as the parent parameter, the view has not been added to the current content view and so mainActivity is unable to find it and now since I am explicitly using the parent view that is returned by the inflater to find the TextView it is working.

提交回复
热议问题