gpt4 book ai didi

android - SwipeRefreshLayout 得到 ACTION_MOVE 事件但没有 Activity 指针 id

转载 作者:行者123 更新时间:2023-12-04 11:15:37 25 4
gpt4 key购买 nike

我将 SwipeRefreshLayout 与 AppCompat ListFragment 一起使用。当我拉刷新时它似乎工作正常,但有时在日志中我可以看到以下错误。如果我在刷新或刚刚完成刷新时再次拉出列表,就会发生这种情况。

E/SwipeRefreshLayout: Got ACTION_MOVE event but don't have an active pointer id.

我的布局代码是:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">

<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/activity_main_swipe_refresh_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">

<ListView
android:id="@id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
/>
</android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout>

在 ListFragment 我覆盖 onCreateView
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);

View view = inflater.inflate(R.layout.list_layout, container, false);


swipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.activity_main_swipe_refresh_layout);
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
log.d("swipeRefreshLayout onRefresh");
onRefreshList();
}
});

adapter = new ItemAdapter(getActivity());
setListAdapter(adapter);
return view;
}

最佳答案

初始化 swipeRefreshLayout 后尝试放置此代码

swipeRefreshLayout = (SwipeRefreshLayout)view.findViewById(R.id.activity_main_swipe_refresh_layout);
// put the code below
swipeRefreshLayout.post(new Runnable() {
@Override
public void run() {
swipeRefreshLayout.setRefreshing(true);
onRefreshList();
}
});

swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
@Override
public void onRefresh() {
log.d("swipeRefreshLayout onRefresh");
onRefreshList();
}
});

关于android - SwipeRefreshLayout 得到 ACTION_MOVE 事件但没有 Activity 指针 id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35848182/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com