小编eC *_*oid的帖子

Dagger 2如何执行构造函数注入

我上课了

public class DialogUtils
{
    private Context context;

    @Inject
    public DialogUtils(Context context)
    {
        this.context = context;
    }
}
Run Code Online (Sandbox Code Playgroud)

在我的活动类中,我已经做了但是我在dialogUtils实例上得到空指针异常.

public class LoginActivity extends Activity{
@Inject DialogUtils dialogUtils;
}
Run Code Online (Sandbox Code Playgroud)

我知道如何通过模块和组件注入依赖,但不知道如何使用构造注入.任何帮助深表感谢.

android dagger-2

9
推荐指数
1
解决办法
4888
查看次数

谷歌地图Android Sdk集成没有结算帐户(没有信用卡)

如果某人没有信用卡并且只想依靠200美元的信用额度,因为我的用户群非常小,该怎么办?

来自定价页面

是否有其他可以免费使用的API或SDK?

Yes. In addition to the $200 monthly free credit, all users get:

    Free Maps usage for iOS, Android, and Embed (for displaying maps only)
    Free Maps URLs
Run Code Online (Sandbox Code Playgroud)

但是当我尝试在控制台中创建项目时,它会要求我设置结算帐户.我没有任何信用卡.请帮忙.

android google-maps-android-api-2

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

错误:资源 android:attr/colorError 未找到

将我的 compileSdkVersion、TargetSdkVersion 和库版本升级到 28 后。我的项目将不再构建。我目前专门为“mFlavor”构建,所以请忽略其他口味。手动命令gradlew assembleMFlavorDebug

这是我的 build.gradle(项目级别)

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    repositories {
        google()
        mavenCentral()
        maven {url 'https://maven.fabric.io/public'}
        jcenter()
    }



    dependencies {
        classpath 'com.android.tools.build:gradle:3.2.1'
        /*classpath 'com.google.gms:google-services:3.1.1'*/
        classpath 'com.google.gms:google-services:4.2.0'
        // classpath 'com.google.gms:google-services:2.0.0-alpha3'

        classpath 'io.fabric.tools:gradle:1.25.4'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        maven { url "https://maven.google.com"}
        maven{url "https://jitpack.io"}
        google()
        jcenter()
    } …
Run Code Online (Sandbox Code Playgroud)

android gradle android-gradle-plugin

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

ScrollView 在 CardView 中不起作用

我已经搜索过了,但没有一个答案对我有帮助。

这是我的布局 xml:

<android.support.v7.widget.CardView
        android:id="@+id/layout_building"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginTop="@dimen/_8dp"
        app:layout_constraintEnd_toStartOf="@+id/scrollview_nested_fragment_container"
        app:layout_constraintHorizontal_weight="1"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/views_container">

        <ScrollView
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

        <LinearLayout
            android:id="@+id/layout_building_container"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"/>

        </ScrollView>

    </android.support.v7.widget.CardView>
Run Code Online (Sandbox Code Playgroud)

我正在LinearLayout通过代码向我的动态添加子视图。我也尝试将ScrollView标签移动到包装,CardView但仍然没有运气。这是限制CardView还是有人知道对此的有效解决方案。

android android-scrollview android-cardview

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

对话框打开时,布局混乱

我面临一个非常奇怪的错误,其中一个布局的父级是ConstraintLayout.当一个diaog打开时,后面的布局会自动开始构造和移动.关于bug的想法请参考附加的gif.请检查我的代码,看看我做错了什么.

这是我的布局.

<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/picker_bg"
    android:padding="@dimen/_8dp">

    <!-- Pick details layout starts -->

    <android.support.v7.widget.CardView
        android:id="@+id/load_details_card"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:cardCornerRadius="@dimen/_1dp"
        app:cardElevation="@dimen/_2dp"
        app:layout_constraintEnd_toStartOf="@+id/load_status_card"
        app:layout_constraintStart_toStartOf="parent">

        <android.support.constraint.ConstraintLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:paddingBottom="@dimen/_8dp"
            android:paddingEnd="@dimen/_12dp"
            android:paddingStart="@dimen/_12dp"
            android:paddingTop="@dimen/_8dp">

            <TextView
                android:id="@+id/load_id"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:gravity="center_horizontal"
                android:text="@string/load_id"
                android:textSize="@dimen/_16sp"
                app:layout_constraintEnd_toStartOf="@+id/stops"
                app:layout_constraintHorizontal_chainStyle="packed"
                app:layout_constraintLeft_toLeftOf="parent"
                app:layout_constraintStart_toStartOf="parent" />

            <TextView
                android:id="@+id/load_id_value"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/_6dp"
                android:gravity="center_horizontal"
                android:text="900"
                android:textSize="@dimen/_16sp"
                app:layout_constraintEnd_toEndOf="@+id/load_id"
                app:layout_constraintStart_toStartOf="@+id/load_id"
                app:layout_constraintTop_toBottomOf="@+id/load_id" />

            <TextView
                android:id="@+id/stops"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginStart="@dimen/_12dp"
                android:gravity="center_horizontal"
                android:text="@string/stops"
                android:textSize="@dimen/_16sp"
                app:layout_constraintEnd_toStartOf="@+id/truck"
                app:layout_constraintStart_toEndOf="@+id/load_id" />

            <TextView
                android:id="@+id/stops_value"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/_6dp"
                android:gravity="center_horizontal"
                android:text="3"
                android:textSize="@dimen/_16sp"
                app:layout_constraintEnd_toEndOf="@+id/stops"
                app:layout_constraintStart_toStartOf="@+id/stops"
                app:layout_constraintTop_toBottomOf="@+id/stops" />

            <TextView
                android:id="@+id/truck" …
Run Code Online (Sandbox Code Playgroud)

android android-constraintlayout

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

是否可以将 cameraX 或 Camera2 缩放到 Api 最大缩放限制之外

所以我正在尝试制作一个双筒望远镜/望远镜类的应用程序,但问题是我想放大到最大。我看到商店里有应用程序可以做到这一点,但不确定如何。我尝试过 cameraX linearZoom 方法,但它只能在 0f - 1f 之间的范围内工作,或者是否可以使用 Camera2 api 来做到这一点?任何帮助将不胜感激。请注意,我只是在尝试或研究了一整天不同的事情后才发布了这个问题。

谢谢

android android-camera2 android-camerax

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