首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SwipeRefreshLayout卡住

SwipeRefreshLayout卡住
EN

Stack Overflow用户
提问于 2016-03-17 14:05:33
回答 1查看 1.4K关注 0票数 2

我的SwipeRefreshLayout有点问题,基本上它会刷新页面,但是动画被卡住了。

在我的刷新中,我调用了其他类的Asynctask,因此我猜存在一个问题。

我的SwipeRefresh听众:

代码语言:javascript
复制
swipeRefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            MyClassAdapter.updateChallenges();
            MyClassAdapter.notifyDataSetInvalidated();
            swipeRefresh.setRefreshing(false);
        }
    });

我的同步任务:

代码语言:javascript
复制
protected MyClass[] doInBackground(String... param) {
    URL oracle;
    BufferedReader in;
    String inputLine;
    String jsonFile = "";

    try {
        Thread.sleep(4000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
    try {
        oracle = new URL("someURL");
        in = new BufferedReader(
                new InputStreamReader(oracle.openStream()));
        while ((inputLine = in.readLine()) != null) {
            jsonFile += inputLine;
        }
        in.close();
    } catch (IOException e) {
        e.printStackTrace();
    }
    return jsonToStructure(jsonFile);
}

XML:

代码语言:javascript
复制
<android.support.v4.widget.SwipeRefreshLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/swipe_to_refresh"
    android:layout_alignParentTop="true"
    android:layout_alignParentStart="true">

    <ListView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/list_view"
        android:layout_alignParentTop="true"
        android:layout_alignParentEnd="true"
        android:layout_alignParentBottom="true" />

</android.support.v4.widget.SwipeRefreshLayout>

正如我所说的,适配器确实会刷新,但是swipeRefreshLayout的动画被卡住了。

我添加了Thread.sleep(4000),只是为了看看它是否能并行运行,但是它所做的只是等到任务完成,也就是4秒,然后停止.

你们有什么想法吗?谢谢你

EN

回答 1

Stack Overflow用户

发布于 2018-10-26 07:21:23

这可能是“滚动冲突”问题,请检查父视图中的onInterceptTouchEvent()dispatchTouchEvent()

SwipeRefreshLayout卡住了,这是因为您的swipeRefreshLayout无法获得touchEvent,或者他们将触摸事件分派给子视图,这就是为什么它会卡住。

这可能会有帮助,请检查这个:Android开发人员-管理ViewGroup中的触摸事件

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/36062921

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档