[英]Endless recycler view inside coordinatorLayout
How can we achieve endless recyclerview inside co-ordinator layout?我们如何在协调器布局中实现无尽的回收器视图? Below is my layout.下面是我的布局。
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
android:theme="@style/ParentTownMaterialTheme.AppBarOverlay">
// Inside linear layout child views are there
<LinearLayout
android:id="@+id/linear_scroll_enter"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_scrollFlags="scroll|enterAlways"/>
</android.support.design.widget.AppBarLayout>
<android.support.v7.widget.RecyclerView
android:id="@+id/response_lv"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/linear_scroll_enter"
android:background="@android:color/white"
android:clipToPadding="false"
android:divider="@android:color/transparent"
android:paddingBottom="6dp"
android:paddingTop="6dp"
android:scrollbars="vertical"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
</android.support.design.widget.CoordinatorLayout>
Endless recyclerview working here but the in reverse order.无尽的 recyclerview 在这里工作,但顺序相反。 such as :如 :
item 10
item 9
item 8
item 7
item 6
----------
LOAD MORE
----------
item 5
item 4
item 3
item 2
item 1
It should be like :它应该是这样的:
item 1
item 2
item 3
item 4
item 5
-----------
LOAD MORE
-----------
item 6
item 7
item 8
item 9
item 10
Here is java code :这是java代码:
response_lv.setHasFixedSize(false);
final LinearLayoutManager mLayoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, true);
response_lv.setLayoutManager(mLayoutManager);
response_lv.addItemDecoration(new DividerItemDecoration(this, LinearLayoutManager.VERTICAL));
response_lv.setItemAnimator(new DefaultItemAnimator());
response_lv.setAdapter(profileFragmentRecyclerAdapter);
response_lv.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
if (dy > 0) {
if ((mLayoutManager.getChildCount() + mLayoutManager.findFirstVisibleItemPosition()) >= mLayoutManager.getItemCount()) {
Log.d("TAG", "End of list");
totalItemCount = mLayoutManager.getItemCount();
lastVisibleItem = mLayoutManager.findLastVisibleItemPosition();
if (!isLoading && totalItemCount <= (lastVisibleItem + visibleThreshold)) {
isLoading = true;
current_page++;
setLoadingView();
new ProfileAsyncTask().execute();
}
}
}
}
});
Any help appreciated.任何帮助表示赞赏。 Thanks.谢谢。
Currently, you're instructing the LayoutManager
to reverse its layouts (that's what the 3rd/boolean parameter is for).目前,您正在指示LayoutManager
反转其布局(这就是第三个/布尔参数的用途)。 Hence, the order is reversed.因此,顺序颠倒了。
You'll want to change:你会想要改变:
final LinearLayoutManager mLayoutManager =
new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, true);
To:到:
final LinearLayoutManager mLayoutManager =
new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
Which would be the same as just calling:这与仅调用相同:
final LinearLayoutManager mLayoutManager = new LinearLayoutManager(this);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.