小编P.L*_*and的帖子

typescript无法使用react-native将标头添加到获取api

我正在使用来自react-native的Fetch API,并且正在使用打字稿。我的代码如下所示:

let responseLogin = await fetch('http://url_example', {
        method: 'POST',
        headers: {'Content-Type':'application/json'},
        body: requestBody
    });
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误,标题是:

 Argument of type '{ method: string; headers: { 'Content-Type': string; }; body: string; }' is not assignable to parameter of type 'RequestInit'.
  Types of property 'headers' are incompatible.
    Type '{ 'Content-Type': string; }' is not assignable to type 'Headers | string[][]'.
      Object literal may only specify known properties, and ''Content-Type'' does not exist in type 'Headers | string[][]'.
Run Code Online (Sandbox Code Playgroud)

我也尝试创建一个自定义标头,但没有任何运气:

    let requestHeaders = new Headers(); …
Run Code Online (Sandbox Code Playgroud)

json typescript react-native fetch-api

11
推荐指数
3
解决办法
6297
查看次数

Android Studio:Gradle sync失败:Project:app声明了依赖项

我在Android Studio 2.3中工作,我想使用我在github上找到的库(https://github.com/henrychuangtw/Android-ChatHead)并且没有Jar文件.在settings.gradle中,我已经声明了库所在的目录,如下所示:

include ':app'
include ':Android-ChatHead'

project(':Android-ChatHead').projectDir=new File('/Users/lorand/AndroidStudioProjects/Doritest/android_chatHeads')
Run Code Online (Sandbox Code Playgroud)

我还将库添加到build.gradle依赖项中:

dependencies {

        compile fileTree(dir: 'libs', include: ['*.jar'])

        compile project(':Android-ChatHead')

        androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
            exclude group: 'com.android.support', module: 'support-annotations'
        })
        compile 'com.android.support:appcompat-v7:25.1.1'
        compile 'com.android.support.constraint:constraint-layout:1.0.2'
        testCompile 'junit:junit:4.12'
    }
Run Code Online (Sandbox Code Playgroud)

在此之后,如果我同步,我会收到此错误:

Gradle sync失败:Project:app声明从配置'compile'到配置'default'的依赖关系,它未在项目描述符中声明:Android-ChatHead.有关更多详细信息,请参阅IDE日志(帮助|显示日志)

如果我将/ app添加到settings.gradle文件路径的末尾,则会出现以下错误:

Error:Dependency Doritest:Android-ChatHead:unspecified on project core resolves to an APK archive which is not supported as a compilation dependency. 
File: /Users/lorand/AndroidStudioProjects/Doritest/android_chatHeads/Android-ChatHead/app/build/outputs/apk/Android-ChatHead-release-unsigned.apk
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚我应该做些什么.

android gradle android-studio build.gradle

6
推荐指数
1
解决办法
1万
查看次数

android - 如何以编程方式设置角半径?

我有两个ListViews(leftList,rightList).我也有一个TextView用作行视图的两个.我有一个矩形可绘制的形状,并将其设置为背景TextView.

我想改变这个形状并在左边有圆角.

我尝试了什么:

       GradientDrawable gradientDrawable = new GradientDrawable();
       // gradientDrawable.setCornerRadius(30);
        ((GradientDrawable)gradientDrawable.mutate()).setCornerRadius(30);

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            viewHolderPattern.digits.setBackground(gradientDrawable);
        }
Run Code Online (Sandbox Code Playgroud)

我已经在drawable中创建了一个新的布局,右边的半径设置并将其设置为textView setBackgroundRescource但仍然无效.

我在两个listViews中用作项目的TextView

<TextView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:id="@+id/digitsTextView"
    android:textSize="15dp"
    android:paddingTop="7dp"
    android:paddingBottom="8dp"
    android:fontFamily="monospace"
    android:textColor="@color/selected_items"
    android:background="@drawable/digital_text_shape">
</TextView>
Run Code Online (Sandbox Code Playgroud)

形状布局digital_text_shape.xml

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:shape="rectangle">
    <stroke
        android:width="1dp"
        android:color="@color/orange" />
    <solid android:color="@color/orange" />
    <corners
        android:bottomLeftRadius="20dp"
        android:bottomRightRadius="0dp"
        android:topLeftRadius="20dp"
        android:topRightRadius="0dp"
        />
    <padding
        android:bottom="0dp"
        android:left="20dp"
        android:right="0dp"
        android:top="0dp" />
</shape>
Run Code Online (Sandbox Code Playgroud)

左侧列表和右侧列表

<!-- Left ListView -->
                <LinearLayout
                    android:layout_width="match_parent"
                    android:layout_height="wrap_content"
                    android:layout_weight="1"
                    >
                        <ListView
                            android:layout_width="match_parent"
                            android:layout_height="match_parent"
                            android:layout_gravity="center_horizontal"
                            android:id="@+id/left_listView"
                            android:divider="@android:color/transparent" …
Run Code Online (Sandbox Code Playgroud)

android listview rounded-corners textview

5
推荐指数
2
解决办法
8551
查看次数

React-Native React-Navigation 标题按钮 testID

有没有一种方法可以将 testID 和accessibilityLabel 添加到标题按钮(例如标题后退按钮),以便能够编写自动化测试?

react-native react-navigation

5
推荐指数
1
解决办法
5125
查看次数

React-Native 地理定位中的超时和最大年龄是多少

我目前正在学习react-native,我正在开发一个使用地理定位来查找和更新我当前位置的应用程序,我正在遵循该教程,在教程中我必须使用带有超时和maximumAge选项属性。

navigator.geolocation.getCurrentPosition((pozitie)=>{
        var lat = parseFloat(position.coords.latitude)
        var long = parseFloat(position.coords.longitude)

        // create an object with the current position taken from the geolocation chip
        var initialLocation = {
          latitude = lat,
          longitude = long,

          // Delta is the viewing angle on the location of the user
          latitudeDelta: LATITUDE_DELTA,
          longitudeDelta: LONGITUDE_DELTA
        }
        // Now we are seting initial position to the initial location 
        this.setState({initialPositionOnTheMap: initialLocation})

        // we set the marker to the initial location and then the display …
Run Code Online (Sandbox Code Playgroud)

geolocation react-native react-native-ios

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

Flutter - 如何控制 ListView 构建器的速度?

我有一个 ListView.builder,我想控制 ListView 中的滚动速度,但除了扩展模拟之外我找不到解决方案,然后我覆盖速度,然后扩展 ScrollingPhysics 类并提供速度从那里。但我不知道我该怎么做。

您是否有其他解决方案或示例来说明如何执行此操作?

dart flutter

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