Reputation: 1071
i have attached the Swipe Refresh Layout as a top parent node to offer pull down refresh option to user.
So when i scroll down, i cant able to scroll, automatically the pull down option starts loading.
i have searched some stack overflow question regarding the same issue. they are saying listen the scrolling and disable the pull down option based on the list view current index.
i have tried to listen it. but i cant able listen any event when scrolling down.
my list view object:
mListView = (ListView) getView().findViewById(android.R.id.list);
can anyone please help me. any other interesting solution or work around.
Upvotes: 2
Views: 1471
Reputation: 22212
In my case I solved the problem by changing the Scrollview by a NestedScrollView.
After switching to a NestedScrollView it worked correctly
Upvotes: 2
Reputation: 4122
I did it this way and it's working perfectly:
class YourActivity extends AppCompatActivity implements ViewTreeObserver.OnScrollChangedListener {
@Override
protected void onStart() {
super.onStart();
mListView.getViewTreeObserver().addOnScrollChangedListener(this);
}
@Override
protected void onStop() {
super.onStop();
mListView.getViewTreeObserver().removeOnScrollChangedListener(this);
}
@Override
public void onScrollChanged() {
if (mListView.getFirstVisiblePosition() == 0) {
swipeRefresh.setEnabled(true);
} else {
swipeRefresh.setEnabled(false);
}
}
}
Hope this will help.
Upvotes: 6