随笔分类 -  android-kotlin-开发实战

android-kotlin-开发实战
摘要:一,代码: 在activity中增加一行: getSupportActionBar()?.hide() 例子: class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) 阅读全文
posted @ 2025-09-06 22:07 刘宏缔的架构森林 阅读(23) 评论(0) 推荐(0)
摘要:一,引入lifecycle 1,libs.versions.toml [versions] lifecycle = "2.9.1" [libraries] # lifecycle androidx-lifecycle-livedata-core-ktx = { group = "androidx.l 阅读全文
posted @ 2025-09-06 22:07 刘宏缔的架构森林 阅读(45) 评论(0) 推荐(0)
摘要:一,安装第三方库 build.gradle.kts中添加 implementation("com.squareup.retrofit2:retrofit:2.9.0") implementation("com.squareup.retrofit2:converter-gson:2.9.0") imp 阅读全文
posted @ 2025-09-06 22:07 刘宏缔的架构森林 阅读(33) 评论(0) 推荐(0)
摘要:一,报错信息: e: file:///Users/liuhongdi/StudioProjects/Okdemo2/app/src/main/java/com/example/okdemo2/fragment/ApiService.kt:14:67 This declaration needs op 阅读全文
posted @ 2025-09-06 22:07 刘宏缔的架构森林 阅读(153) 评论(0) 推荐(0)
摘要:一,报错信息: org.jetbrains.kotlin.util.FileAnalysisException: While analysing /Users/liuhongdi/StudioProjects/Okdemo2/app/src/main/java/com/example/okdemo2 阅读全文
posted @ 2025-09-06 22:07 刘宏缔的架构森林 阅读(663) 评论(0) 推荐(0)
摘要:一,在项目中添加 Kotlin Serialization 插件和依赖 编辑libs.versions.toml,增加以下内容: [versions] kotlin = "2.0.21" kotlinxSerializationJson = "1.9.0" [libraries] # kotlin 阅读全文
posted @ 2025-09-06 22:07 刘宏缔的架构森林 阅读(191) 评论(0) 推荐(0)
摘要:一,报错信息: FATAL EXCEPTION: main Process: com.example.okdemo2, PID: 3158 java.net.UnknownServiceException: CLEARTEXT communication to www.testit.net not 阅读全文
posted @ 2025-09-06 22:07 刘宏缔的架构森林 阅读(86) 评论(0) 推荐(0)
摘要:一,启用 编辑build.gradle.kts android { namespace = "com.example.okdemo2" compileSdk = 35 buildFeatures { buildConfig = true viewBinding = true } 二,代码中使用 pa 阅读全文
posted @ 2025-09-06 22:07 刘宏缔的架构森林 阅读(37) 评论(0) 推荐(0)
摘要:一,安装第三方库 build.gradle.kts中添加 implementation("com.squareup.retrofit2:retrofit:2.9.0") implementation("com.squareup.retrofit2:converter-gson:2.9.0") imp 阅读全文
posted @ 2025-09-06 22:07 刘宏缔的架构森林 阅读(21) 评论(0) 推荐(0)
摘要:一,添加fragment fragment的ui <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools=" 阅读全文
posted @ 2025-09-06 22:07 刘宏缔的架构森林 阅读(24) 评论(0) 推荐(0)
摘要:一,如图: 查看生成的文件: 指定为默认activity: 编辑:AndroidManifest.xml 把: <activity android:name=".MainActivity" android:exported="false" /> 替换为: <activity android:name 阅读全文
posted @ 2025-09-06 22:07 刘宏缔的架构森林 阅读(16) 评论(0) 推荐(0)
摘要:一,创建项目 二,完成后效果 阅读全文
posted @ 2025-09-06 08:39 刘宏缔的架构森林 阅读(24) 评论(0) 推荐(0)