Recyclerview,Livedata,生命周期依赖性
你好,互联网的人。
我叫保罗。
我已经开始使用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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论