Recyclerview,Livedata,生命周期依赖性

发布于 2025-01-26 07:29:15 字数 1052 浏览 3 评论 0原文

你好,互联网的人。

我叫保罗。

我已经开始使用Kotlin学习Android开发,最近我一直在关注有关Recyclerview,Livedata和Lifececle的几个教程。

首先,我诚实地忘了宣布Gradle脚本中的依赖项。 但是我发现该功能实际上是按预期工作的。

有人可以向我解释一下这种现象:

  • 是因为Android Studio“看到“我的进口”并自动“定义”并下载了依赖关系?
  • 是因为CompilesDK版本吗?

这是我从一个项目中的一个项目中的一个示例,

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

这也是我的配置

defaultConfig {
        applicationId "com.example.myrecycler"
        minSdk 23
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

谢谢!

Hello kind people of the internet.

My name is Paul.

I've started to learn Android development using Kotlin, lately I've been following a couple of tutorials regarding RecyclerView, LiveData and Lifecycle.

At first I honestly forgot to declare the dependencies inside my gradle script.
But I have discovered that the functionality actually works as expected.

Can somebody please explain to me this phenomenon:

  • is it because Android Studio "saw" my imports and automatically "defined" and downloaded the dependencies ?
  • is it because of the compileSdk version?

Here is a sample of my dependencies block from one of my projects

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

Also here is my config

defaultConfig {
        applicationId "com.example.myrecycler"
        minSdk 23
        targetSdk 32
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文