Je veux avoir une pagination pour le recyclagemais, dans mon cas, le recyclerView est à l'intérieur d'un ScrollView. Donc, onscrollListener ne fonctionne pas comme prévu. Je compte donc trouver la fin de défilement pour ScrollView et déclencher la demande de page suivante.
Est-ce une bonne solution ou quelqu'un a-t-il une meilleure idée?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ScrollView android:layout_width="match_parent"
android:layout_height="match_parent" android:fillViewport="false">
<LinearLayout android:layout_width="match_parent"
android:orientation="vertical"
android:layout_height="wrap_content">
<FrameLayout android:id="@+id/headerContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<android.support.v4.view.ViewPager
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</ScrollView>
</LinearLayout>
Réponses:
0 pour la réponse № 1Vous pouvez utiliser le code suivant pour intercepter les parchemins de RecyclerView et pouvez ajuster vos événements de défilement en fonction de cela, j'espère que cela vous aidera
mList.addOnItemTouchListener(new RecyclerView.OnItemTouchListener() {
float rawX;
int mSlop = ViewConfiguration.get(getActivity()).getScaledTouchSlop();
@Override
public boolean onInterceptTouchEvent(RecyclerView v, MotionEvent event) {
switch (event.getActionMasked()) {
case MotionEvent.ACTION_DOWN:
v.getParent().requestDisallowInterceptTouchEvent(true);
rawX = event.getRawX();
break;
case MotionEvent.ACTION_CANCEL:
case MotionEvent.ACTION_UP:
v.getParent().requestDisallowInterceptTouchEvent(false);
rawX = 0f;
break;
case MotionEvent.ACTION_MOVE:
if (Math.abs(rawX - event.getRawX()) > mSlop)
v.getParent().requestDisallowInterceptTouchEvent(true);
break;
}
return false;
}
@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
});