小编Aru*_*unL的帖子

未针对CoordinatorLayout行为触发onNestedFling或onNestedPreFling

向上弹动时,不会为CoordinatorLayout中的NestedScrollView触发onNestedFling或onNestedPreFling行为回调。但是,当我向下飞行时,它们会被触发。任何已知问题?

当我用RecyclerView替换NestedScrollView时,会触发上述回调。

只是为了澄清,自定义行为类是:

public class DummyBehavior extends CoordinatorLayout.Behavior<View> {
    public DummyBehavior() {
    }

    public DummyBehavior(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onStartNestedScroll(CoordinatorLayout coordinatorLayout, View child, View directTargetChild, View target, int nestedScrollAxes) {
        Log.i("onStartNestedScroll", "true");
        return true;
    }

    @Override
    public boolean onNestedPreFling(CoordinatorLayout coordinatorLayout, View child, View target, float velocityX, float velocityY) {
        Log.i("onNestedPreFling", "true");
        return super.onNestedPreFling(coordinatorLayout, child, target, velocityX, velocityY);
    }

    @Override
    public boolean onNestedFling(CoordinatorLayout coordinatorLayout, View child, View target, float velocityX, float velocityY, boolean consumed) { …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview android-coordinatorlayout android-nestedscrollview

5
推荐指数
0
解决办法
1209
查看次数

Golang Gokogiri递归xpath异常

我试图在html文档上执行xpath操作.我想做一个两级xpath查询.html文档"index.html"如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
    <div class="head">
        <div class="area">
            <div class="value">10</div>
        </div>
        <div class="area">
            <div class="value">20</div>
        </div>
        <div class="area">
            <div class="value">30</div>
        </div>
    </div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

我想首先使用class ="area"获取所有div,然后使用Gokogiri在golang中使用class ="value"递归获取div.

我的代码如下:package main

import (
    "fmt"
    "io/ioutil"

    "github.com/moovweb/gokogiri"
    "github.com/moovweb/gokogiri/xpath"
)

func main() {
    content, _ := ioutil.ReadFile("index.html")

    doc, _ := gokogiri.ParseHtml(content)
    defer doc.Free()

    xps := xpath.Compile("//div[@class='head']/div[@class='area']")
    xpw := xpath.Compile("//div[@class='value']")
    ss, _ := doc.Root().Search(xps)
    for _, s := range ss {
        ww, _ := s.Search(xpw)
        for _, w …
Run Code Online (Sandbox Code Playgroud)

xml recursion xpath go

4
推荐指数
1
解决办法
1650
查看次数