And*_*oid 5 android freeze swiperefreshlayout
在使用API 21及更高版本的Nexus 5上,一切正常,但在使用API 4.2.2的旧版三星设备上,我在SwipeRefreshLayout中遇到以下错误.
有没有遇到类似的人?
当我下拉刷新刷新冻结时,直到我开始向上滚动.
这是一个非常不受欢迎的问题,但是它会与新支持库更新中出现的问题有关吗?我目前正在使用以下支持库:
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:support-v4:22.2.1'
compile 'com.android.support:cardview-v7:22.2.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:palette-v7:22.2.1'
compile 'com.android.support:recyclerview-v7:22.2.1'
Run Code Online (Sandbox Code Playgroud)
这个问题在我的几个活动中发生,但作为一个例子,我实例化SwipeRefreshLayout就像这样,没有什么不寻常的.它在里面Fragment:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?android:colorBackground"
android:orientation="vertical">
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/swipeToRefresh"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.SwipeRefreshLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我初始化之SwipeRefreshLayout类的:
private void initSwipeRefreshLayout() {
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
mSwipeRefreshLayout.setRefreshing(true);
refreshContent();
}
});
mSwipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
android.R.color.holo_green_light,
android.R.color.holo_orange_light,
android.R.color.holo_red_light);
}
private void initRecyclerViewScrollListener() {
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
visibleItemCount = mRecyclerView.getChildCount();
totalItemCount = mLayoutManager.getItemCount();
firstVisibleItem = mLayoutManager.findFirstCompletelyVisibleItemPosition();
lastVisibleItem = mLayoutManager.findLastCompletelyVisibleItemPosition();
int pageMultiplier = page * PER_PAGE;
if (!loading) {
if ((pageMultiplier == totalItemCount) && (lastVisibleItem == pageMultiplier - 1)) {
loading = true;
page += 1;
mPresenter.loadMoreStuff(mStuff.getId(), page, PER_PAGE);
mSwipeRefreshLayout.setRefreshing(true);
}
}
}
});
}
Run Code Online (Sandbox Code Playgroud)
编辑:如果这是相关的,这些问题都发生在里面Fragments
我相信问题的发生是由于SwipeRefreshLayoutv23 与 v22 相比的变化RecyclerView,. 切换到 v23.0.1 后一切正常
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:palette-v7:23.0.1'
compile 'com.android.support:recyclerview-v7:23.0.1'
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
611 次 |
| 最近记录: |