小编Ily*_*tov的帖子

React Native fetch() 返回奇数的 json 响应项

我正在尝试从名为 OpenWeatherMap 的服务获取数据作为 JSON,因此在我的 componentWillMount 方法中,我正在调用 fetch() 以通过 url 返回数据。我现在的代码是:

this.weather = fetch(url).then(response => response.json()).then(responseJson => responseJson);

它有效,但在 JSON 响应中返回奇数数据,我现在的 JSON 响应是:

{"_40":0,"_65":1,"_55":{here_the_correct_response}}

但我希望我的响应没有这些奇怪的下划线索引,只是纯 JSON 响应

javascript json fetch react-native-android

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

CardView 触控提升

我是 Android 开发的新手,我正在尝试对 cardview 点击产生提升效果。我在 stackoverflow上找到了关于这个主题的几个教程 this onethis onethis answer。所有这些教程都建议像这样创建 xml 文件

<selector xmlns:android="http://schemas.android.com/apk/res/android">  
    <item android:state_enabled="true" android:state_pressed="true">
        <set>
            <objectAnimator android:duration="@android:integer/config_shortAnimTime"
                android:propertyName="translationZ"
                android:valueTo="6dp"
                android:valueType="floatType" />
        </set>
    </item>
    <item>
        <set>
            <objectAnimator android:duration="@android:integer/config_shortAnimTime"
                android:propertyName="translationZ"
                android:valueTo="0"
                android:valueType="floatType" />
        </set>
    </item>
</selector>
Run Code Online (Sandbox Code Playgroud)

然后放到res/anim目录下。但是,当我尝试将此代码放入 res/anim/lift_on_touch.xml 时,它给了我错误“必须声明元素选择器”并建议将此文件移动到 animator 或 drawable 目录。我把它移动到 animator-v21 目录,没有错误,但它不起作用。在这种情况下我该怎么办?

PS:我将 clickable 和 stateListAnimator 属性放在我的 CardView 中。这是我的 CardView:

<android.support.v7.widget.CardView
    android:layout_width="0dp"
    android:layout_height="0dp"
    app:cardElevation="2dp"
    android:clickable="true"
    android:stateListAnimator="@animator/lift_on_touch"
    app:layout_constraintTop_toTopOf="@+id/top_guideline"
    app:layout_constraintRight_toRightOf="@+id/right_guideline"
    app:layout_constraintLeft_toLeftOf="@+id/left_guideline"
    app:layout_constraintBottom_toBottomOf="@+id/inner_top_guideline" />
Run Code Online (Sandbox Code Playgroud)

animation android material-design

3
推荐指数
1
解决办法
1486
查看次数