1

I need to dynamically footer which can be add or remove when ever scrollview reaches the end. at some point I also need it to be visible and at other times I need it to be invisible , since I can't change visibility is there any other way.

I am having an on scroll listener like this

  listViewComments.setOnScrollListener(new AbsListView.OnScrollListener() {
            @Override
            public void onScrollStateChanged(AbsListView absListView, int i) {
                if (i == AbsListView.OnScrollListener.SCROLL_STATE_IDLE
                        && (listViewComments.getLastVisiblePosition() - listViewComments.getHeaderViewsCount() -
                        listViewComments.getFooterViewsCount()) >= (commentAdapter.getCount() - 1)) {
                   // removing or adding footer
                }
            }

when I do like this it results in flickering of the footer even if I am calling the function once, sometimes when I scroll it gets in the middle of my listview items.

Ketan P
  • 4,259
  • 3
  • 30
  • 36

1 Answers1

1

You can add your footer view :

listViewComments.addFooterView(yourFooterView);

and you can remove it :

listViewComments.removeFooterView(yourFooterView);

Don't forget to inflate your footer view first :

View yourFooterView = getLayoutInflater().inflate(R.layout.yourFooterXML, null);
Lubomir Babev
  • 1,892
  • 1
  • 12
  • 14