jetpack : viewmodel 、livedata 、lifecycle依赖

一文搞懂Android-JetPack组件原理之Lifecycle、LiveData、ViewModel与源码分析技巧(2) 各行各样都会淘汰一些能力差的,不仅仅是IT这个行业,所以,不要被程序猿是吃青春饭等等这类话题所吓倒,也不要觉得,找到一份工作,就享受安逸的生活,你在安逸的同时,别人正在奋力的向前跑,这样与别人的差距也就会越来越遥远,加油,希望,我们每一个人,成为更好的自己。BAT大厂面试题、独家面试工具包,资料包括 数据结构、Kotlin、计算机网络、Framework源码、数据结构与算法、小程序、NDK、Flutter《互联网大厂面试真题解析、进阶开发核心学习笔记、全套讲解视频、实战项目源码讲义》点击传送门即可获取。 阅读详情

lifecycle 依赖

//androidx版本 lifecycle
implementation group: 'androidx.lifecycle', name: 'lifecycle-runtime', version: '2.0.0'
implementation group: 'androidx.lifecycle', name: 'lifecycle-common', version: '2.0.0'
implementation group: 'androidx.lifecycle', name: 'lifecycle-livedata', version: '2.0.0'
implementation group: 'androidx.lifecycle', name: 'lifecycle-viewmodel', version: '2.0.0'
//包含livedata + viewmodel
implementation group: 'androidx.lifecycle', name: 'lifecycle-extensions', version: '2.0.0'
//包含kotlin
implementation group: 'androidx.lifecycle', name: 'lifecycle-viewmodel-ktx', version: '2.0.0'
implementation group: 'androidx.lifecycle', name: 'lifecycle-livedata-ktx', version: '2.0.0'
//
implementation group: 'androidx.lifecycle', name: 'lifecycle-common-java8', version: '2.0.0'

//arch版本 lifecycle
implementation group: 'android.arch.lifecycle', name: 'extensions', version: '1.1.1'
implementation group: 'android.arch.lifecycle', name: 'runtime', version: '1.1.1'
implementation group: 'android.arch.lifecycle', name: 'livedata', version: '1.1.1'
implementation group: 'android.arch.lifecycle', name: 'viewmodel', version: '1.1.1'
implementation group: 'android.arch.lifecycle', name: 'livedata-core', version: '1.1.1'
implementation group: 'android.arch.lifecycle', name: 'common', version: '1.1.1'
implementation group: 'android.arch.lifecycle', name: 'common-java8', version: '1.1.1'

查看依赖关系:

//输出依赖关系到txt文件
gradlew -q  :app:dependencies >log.txt  

lifecycle-extensions: 包含 livedata 、viewmodel 、lifecycle

+--- androidx.lifecycle:lifecycle-extensions:2.2.0-alpha01
|    +--- androidx.lifecycle:lifecycle-runtime:2.2.0-alpha01 (*)
|    +--- androidx.arch.core:core-common:2.1.0-beta01 (*)
|    +--- androidx.arch.core:core-runtime:2.1.0-beta01 (*)
|    +--- androidx.fragment:fragment:1.0.0 -> 1.1.0-beta01 (*)
|    +--- androidx.lifecycle:lifecycle-common:2.2.0-alpha01 (*)
|    +--- androidx.lifecycle:lifecycle-livedata:2.2.0-alpha01 (*)
|    +--- androidx.lifecycle:lifecycle-process:2.2.0-alpha01
|    |    \--- androidx.lifecycle:lifecycle-runtime:2.2.0-alpha01 (*)
|    +--- androidx.lifecycle:lifecycle-service:2.2.0-alpha01
|    |    \--- androidx.lifecycle:lifecycle-runtime:2.2.0-alpha01 (*)
|    \--- androidx.lifecycle:lifecycle-viewmodel:2.2.0-alpha01 (*)

lifecycle-livedata-ktx: 包含kotlin 和 livedata

+--- androidx.lifecycle:lifecycle-livedata-ktx:2.2.0-alpha01
|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.20 -> 1.3.41 (*)
|    +--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1 -> 1.3.0-M2 (*)
|    +--- androidx.lifecycle:lifecycle-livedata:2.2.0-alpha01 (*)
|    \--- androidx.lifecycle:lifecycle-livedata-core-ktx:2.2.0-alpha01
|         +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.20 -> 1.3.41 (*)
|         \--- androidx.lifecycle:lifecycle-livedata-core:2.2.0-alpha01 (*)

lifecycle-viewmodel-ktx: 包含kotlin 和 viewmodel

androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0-alpha01
+--- org.jetbrains.kotlin:kotlin-stdlib:1.3.20 -> 1.3.41 (*)
+--- org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1 -> 1.3.0-M2
|    +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.40 -> 1.3.41 (*)
|    \--- org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0-M2
|         +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.40 -> 1.3.41 (*)
|         \--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.40 -> 1.3.41
\--- androidx.lifecycle:lifecycle-viewmodel:2.2.0-alpha01 (*)

lifecycle-runtime: 只包含 lifecycle

+--- androidx.lifecycle:lifecycle-runtime:2.0.0
|    +--- androidx.lifecycle:lifecycle-common:2.0.0
|    |    \--- androidx.annotation:annotation:1.0.0
|    +--- androidx.arch.core:core-common:2.0.0
|    |    \--- androidx.annotation:annotation:1.0.0
|    \--- androidx.annotation:annotation:1.0.0

AndroidX 的 appcompat 包:

implementation 'androidx.appcompat:appcompat:1.0.2'

查看依赖可看到已包含了lifecycle的 viewmodel 、livedata

+--- androidx.appcompat:appcompat:1.0.2
|    +--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    +--- androidx.core:core:1.0.1 -> 1.0.2
|    |    +--- androidx.annotation:annotation:1.0.2
|    |    +--- androidx.collection:collection:1.0.0
|    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    +--- androidx.lifecycle:lifecycle-runtime:2.0.0
|    |    |    +--- androidx.lifecycle:lifecycle-common:2.0.0
|    |    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    |    +--- androidx.arch.core:core-common:2.0.0
|    |    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    \--- androidx.versionedparcelable:versionedparcelable:1.0.0
|    |         +--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |         \--- androidx.collection:collection:1.0.0 (*)
|    +--- androidx.collection:collection:1.0.0 (*)
|    +--- androidx.cursoradapter:cursoradapter:1.0.0
|    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    +--- androidx.legacy:legacy-support-core-utils:1.0.0
|    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    +--- androidx.core:core:1.0.0 -> 1.0.2 (*)
|    |    +--- androidx.documentfile:documentfile:1.0.0
|    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    +--- androidx.loader:loader:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    |    +--- androidx.core:core:1.0.0 -> 1.0.2 (*)
|    |    |    +--- androidx.lifecycle:lifecycle-livedata:2.0.0
|    |    |    |    +--- androidx.arch.core:core-runtime:2.0.0
|    |    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    |    |    |    \--- androidx.arch.core:core-common:2.0.0 (*)
|    |    |    |    +--- androidx.lifecycle:lifecycle-livedata-core:2.0.0
|    |    |    |    |    +--- androidx.lifecycle:lifecycle-common:2.0.0 (*)
|    |    |    |    |    +--- androidx.arch.core:core-common:2.0.0 (*)
|    |    |    |    |    \--- androidx.arch.core:core-runtime:2.0.0 (*)
|    |    |    |    \--- androidx.arch.core:core-common:2.0.0 (*)
|    |    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.0.0
|    |    |         \--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    +--- androidx.localbroadcastmanager:localbroadcastmanager:1.0.0
|    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    \--- androidx.print:print:1.0.0
|    |         \--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    +--- androidx.fragment:fragment:1.0.0
|    |    +--- androidx.core:core:1.0.0 -> 1.0.2 (*)
|    |    +--- androidx.legacy:legacy-support-core-ui:1.0.0
|    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    |    +--- androidx.core:core:1.0.0 -> 1.0.2 (*)
|    |    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
|    |    |    +--- androidx.customview:customview:1.0.0
|    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    |    |    \--- androidx.core:core:1.0.0 -> 1.0.2 (*)
|    |    |    +--- androidx.viewpager:viewpager:1.0.0
|    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    |    |    +--- androidx.core:core:1.0.0 -> 1.0.2 (*)
|    |    |    |    \--- androidx.customview:customview:1.0.0 (*)
|    |    |    +--- androidx.coordinatorlayout:coordinatorlayout:1.0.0
|    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    |    |    +--- androidx.core:core:1.0.0 -> 1.0.2 (*)
|    |    |    |    \--- androidx.customview:customview:1.0.0 (*)
|    |    |    +--- androidx.drawerlayout:drawerlayout:1.0.0
|    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    |    |    +--- androidx.core:core:1.0.0 -> 1.0.2 (*)
|    |    |    |    \--- androidx.customview:customview:1.0.0 (*)
|    |    |    +--- androidx.slidingpanelayout:slidingpanelayout:1.0.0
|    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    |    |    +--- androidx.core:core:1.0.0 -> 1.0.2 (*)
|    |    |    |    \--- androidx.customview:customview:1.0.0 (*)
|    |    |    +--- androidx.interpolator:interpolator:1.0.0
|    |    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    |    +--- androidx.swiperefreshlayout:swiperefreshlayout:1.0.0
|    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    |    |    +--- androidx.core:core:1.0.0 -> 1.0.2 (*)
|    |    |    |    \--- androidx.interpolator:interpolator:1.0.0 (*)
|    |    |    +--- androidx.asynclayoutinflater:asynclayoutinflater:1.0.0
|    |    |    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    |    |    \--- androidx.core:core:1.0.0 -> 1.0.2 (*)
|    |    |    \--- androidx.cursoradapter:cursoradapter:1.0.0 (*)
|    |    +--- androidx.legacy:legacy-support-core-utils:1.0.0 (*)
|    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    +--- androidx.loader:loader:1.0.0 (*)
|    |    \--- androidx.lifecycle:lifecycle-viewmodel:2.0.0 (*)
|    +--- androidx.vectordrawable:vectordrawable:1.0.1
|    |    +--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    \--- androidx.core:core:1.0.0 -> 1.0.2 (*)
|    \--- androidx.vectordrawable:vectordrawable-animated:1.0.0
|         +--- androidx.vectordrawable:vectordrawable:1.0.0 -> 1.0.1 (*)
|         \--- androidx.legacy:legacy-support-core-ui:1.0.0 (*)

androidx.core:core:


+--- androidx.core:core:1.0.1 -> 1.0.2
|    +--- androidx.annotation:annotation:1.0.2
|    +--- androidx.collection:collection:1.0.0
|    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    +--- androidx.lifecycle:lifecycle-runtime:2.0.0
|    |    +--- androidx.lifecycle:lifecycle-common:2.0.0
|    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    +--- androidx.arch.core:core-common:2.0.0
|    |    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    |    \--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|    \--- androidx.versionedparcelable:versionedparcelable:1.0.0
|         +--- androidx.annotation:annotation:1.0.0 -> 1.0.2
|         \--- androidx.collection:collection:1.0.0 (*)

一文搞懂Android-JetPack组件原理之Lifecycle、LiveData、ViewModel与源码分析技巧 2. 手动postValue或setValue触发数据通知 接下来,便以这两个任务链的顺序,对每个方法进行分析。 observer()注册监听者 @MainThread public void observe(@NonNull LifecycleOwner owner, @NonNull Observer<? super T> observer) { assertMainThread(“observe”); if (owner.getLifecycle().getCurrentState() = 阅读详情

相关推荐

Android Jetpack核心组件ViewModel+LiveData+Lifecycle实战demo

Android Jetpack是一套由Google推出的开发库集合,旨在帮助开发者构建高质量、可维护且生命周期安全的Android应用程序。其中,ViewModel、LiveData和Lifecycle是构成Jetpack架构核心的三大组件,共同推动了现代Android应用向响应式、解耦化和生命周期感知方向演进。本章将从整体视角介绍这三个组件的设计初衷与协同价值,阐述它们如何解决传统开发中常见的内存泄漏、数据丢失、UI更新不一致等问题。通过理解Jetpack架构背后的核心思想——关注点分离与。

weixin_33298352的博客 1100

Jetpack(四)—— LiveData

LiveData LiveData是Jetpack提供的一种响应式编程组件,它可以包含任何类型的数据,并在数据发生变化的时候通知给观察者。LiveData特别适合与ViewModel结合在一起使用,虽然它也可以单独用在别的地方,但是在绝大多数情况下,它是使用在ViewModel当中的。 1 LiveData的基本用法 之前编写的那个计数器虽然功能非常简单,但其实是存在问题的。目前的逻辑是,当每次点击Plus One按钮时,都会先给ViewModel中的计数加1,然后立即获取最新的计数。这种方式在单线程模式下

xingyu19911016的博客 2888

androidx-lifecycle-common-2.1.0.jar

androidx-lifecycle-common-2.1.0.jar

AndroidX新库与旧库对应

Old build artifact AndroidX build artifact android.arch.core:common androidx.arch.core:core-common:2.0.0-rc01 android.arch.core:core androidx.arch.core:core:2.0.0-rc01 android.arch.core...

CsdnXiaoCaiJi的博客 7772

Hyper-V显卡直通实战:手把手解决Windows 11虚拟机错误码43(附完整参数配置)

本文详细解析了在Windows 11 Hyper-V虚拟机中配置显卡直通时遭遇错误码43的根源,并提供了从环境检查、核心PowerShell命令(如Set-VMGpuPartitionAdapter)配置到虚拟机内驱动替换的完整实战解决方案,帮助用户彻底解决显卡驱动无法加载的问题。

weixin_29238147的博客 912

NCCL分布式训练中ibv_reg_mr_iova2内存分配失败的3种解决方案(附详细排查流程)

本文深入探讨了NCCL分布式训练中ibv_reg_mr_iova2内存分配失败的3种解决方案,包括快速临时修复、标准系统配置和PAM模块根治方案。详细分析了错误原因,提供了完整的排查流程和性能优化建议,帮助开发者高效解决RDMA网络环境下的内存锁定问题。

nut55的博客 629

Lifecycle源码解析,让你一次学个够!

/ 今日科技快讯 /巴西副总统莫朗当地时间3日在一个视频会议上表示,巴西不担心美方的威胁和施压,不会阻止华为参与该国的5G建设竞标,华为公司掌握的技术远超其它竞争对手。/ 作...

郭霖 2268

戴尔T7920加装RTX3090避坑指南:供电、UEFI与散热全解析

GPU作为高性能计算核心,在AI绘图、大模型推理及游戏渲染等场景中不可或缺。然而,在专业工作站中加装显卡并非简单的即插即用,PCIe供电余量、UEFI启动模式、显存健康状态以及机箱散热风道等底层因素,均直接影响系统稳定性。戴尔T7920这类双路工作站,因其定制电源与服务器级风道设计,在安装高功耗显卡(如RTX 3090)时,常遇到黑屏、掉驱动、瞬间重启等典型问题。通过提前设置UEFI启动、校准供电接口与功率墙,并借助MATS对显存进行检测,可有效规避绝大多数硬件兼容性风险。同时,针对专业计算卡与游戏卡混插场

weixin_29159441的博客 269

Kotlin实战指南十五:协程泄漏

coroutines 引用 GlobalScope MainScope lifecycleScope lifecycleScope 是 KTX 下面的扩展包,Android 帮我们提供了一个扩展引用 使用 注意: 不需要我们手动 , 系统已经帮我们做好了是ViewModel的KTX扩展库,可以让我们在ViewModel中方便的使用Coroutine。如果想要在 ViewModel 中使用作用域,我们需要添加依稀: 使用: lifecycleScope 原理 个人微信号:zhaoyanjun125 ,

赵彦军 3570

API深度集成——OpenClaw与第三方服务无缝对接(2026实战版)

本文介绍了OpenClaw系统与第三方服务的API深度集成技术,重点阐述了RESTful API的实现方案。通过一个功能完善的REST客户端类(RestClient)展示了核心功能:支持请求重试、拦截器机制、错误处理和认证管理等;同时提供了API资源管理器(ApiResourceManager)简化资源操作。这些技术实现了OpenClaw与外部系统的稳定可靠对接,为开发者构建API集成方案提供了2026年的最佳实践。

博客 1218

SSE 传输过程中,丢失空格和回车符,怎么解决?

Server - Sent Events(SSE)即服务器发送事件,是 HTML5 中的一项 Web API,用于实现服务器向客户端浏览器推送实时数据的功能。

941

【Android】Jetpack入门知识总结(LifeCycle,ViewModel,LiveData,DataBinding等)

这里实现一个自定义的,并实现能够响应生命周期事件的功能// 添加注解与生命周期事件关联start();stop();Toast.makeText(context, "点", Toast.LENGTH_SHORT).show();

Patrick_yuxuan的博客 1474

heygem本地部署报错:SQLite3 can only bind numbers, strings, bigints, buffers, and null...如何解决?

🏆本文收录于 《全栈Bug调优(实战版)》 专栏,该专栏专注于分享我在真实项目开发中遇到的各类疑难Bug及其深层成因,并系统提供高效、可复现的解决思路和实操方案。无论你是刚入行的新手开发者,还是拥有多年项目经验的资深工程师,本专栏都将为你提供一条系统化、高质量的问题排查与优化路径,助力你加速成长,攻克技术壁垒,迈向技术价值最大化与职业发展的更高峰🚀!    📌 特别说明: 文中部分技术问题来源于真实生产环境及网络公开案例,均经过精挑细选与系统化整理,并结合多位大厂资深架构师和一线开发多年实战经验沉淀,

**My Coding Family** 3250

Jetpack架构组件库:Lifecycle、LiveData、ViewModel

LifecycleOwner 是单一方法接口,表示类具有 Lifecycle。它具有一种方法(即 getLifecycle()),该方法必须由类实现。 此接口从各个类(如 Fragment 和 AppCompatActivity)抽象化 Lifecycle 的所有权,并允许编写与这些类搭配使用的组件。任何自定义应用类均可实现 LifecycleOwner 接口。 实现 DefaultLifecycleObserver 的组件可与实现 LifecycleOwner 的组件完美配合,因为所有者可以提供生命周期

川峰的博客 2098

【1】Python交叉编译到OpenHarmony标准系统运行(arm32位)

本文介绍如何Python语言如何在OpenHarmony标准系统运行,包括5.0r和4.1r以及4.0r,和未来版本的OpenHarmony版本上。 Python语言在OpenHarmony上使用,需要将Python解释器CPython移植到OpenHarmony标准系统。通过交叉编译的方式。

weixin_58069108的博客 931

30、模态组合规则在振动分析中的应用

本文详细介绍了模态组合规则在振动分析中的应用,重点讨论了绝对峰值叠加法(SRSS)和完全二次组合(CQC)的理论基础、应用场景及优缺点。通过具体工程实例,展示了模态组合规则在地震载荷下结构响应分析中的实际效果,并提供了应用步骤和注意事项,为结构设计和安全评估提供了科学依据。

nice1的博客 226

Jetpack基础(LifeCycle && ViewModel && LiveData)

Jetpack是一个由多个库组成的套件,可帮助开发者遵循最佳做法,减少样板代码并编写可在各种Android版本和设备中一致运行的代码遵循最佳做法消除样板代码减少不一致。

qq_53092981的博客 1070

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

JetPack中的LiveData、ViewModel、LifeCycle

018年谷歌I/O 发布了一系列辅助android开发者的实用工具,合称Jetpack,以帮助开发者构建出色的 Android 应用。 这次发布的 Android Jetpack 组件覆盖以下 4 个方面:Architecture、Foundation、Behavior 以及 UI。 该系列博客介绍一下Jetpack中常用组件,本篇介绍LiveData、ViewModel、LifeCycle。最后借助于https://github.com/android/sunflower 来写一个完整的应用

Huang兄 500

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

Android Jetpack:Lifecycle与LiveData

Lifecycle 是 Jetpack 提供的一个生命周期管理库,它能够帮助开发者更好地管理 UI 组件的生命周期。通过 Lifecycle,开发者可以避免在组件的生命周期中发生内存泄漏、崩溃等问题。LiveData 是 Jetpack 提供的一个可观察数据持有类,它允许开发者在组件的生命周期内安全地观察数据变化。LiveData 能够确保数据变化时,UI 能够及时更新。本文从多个方面详细阐述了 Android Jetpack:Lifecycle 与 LiveData 的相关内容。

2501_92488732的博客 1167

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

AndroidKTX高级技巧:LiveData、Lifecycle与ViewModel扩展的最佳实践

AndroidKTX是一套功能强大的Kotlin扩展库,专为加速Android开发而设计。本文将深入探讨如何利用AndroidKTX中的LiveData、Lifecycle与ViewModel扩展,构建更健壮、更高效的Android应用架构,帮助开发者轻松实现数据驱动UI和生命周期管理。 ## 为什么选择AndroidKTX的架构组件扩展? 在现代Android开发中,LiveData、Lif

gitblog_00570的博客 873

关于 Lifecycle,LiveData,ViewModel

1、Android Jetpack 为何出现 服务端以及前端都有一些为人熟知的开发框架,比如服务端的以前的 Spring MVC 以及现在的 SpringBoot,还有前端的 Vue 等等,但是 Android 却很少出现一个广泛被大家使用的开发框架,如果非得说一个被大家用的最多的框架,那可能还就是 MVC 了,而 MVC 或许是最不是框架的框架了,因为即使用了它,代码依旧是臃肿不堪,耦合严重,...

和小胖 1457

Android-jetPack技术(Lifecycle、ViewModel、LiveData)

Android-jetPack技术 简介 借用文档上面的话 Jetpack 是一套库、工具和指南,可帮助开发者更轻松地编写优质应用。这些组件可帮助您遵循最佳做法、让您摆脱编写样板代码的工作并简化复杂任务,以便您将精力集中放在所需的代码上。 Jetpack 包含与平台 API 解除捆绑的 androidx.* 软件包库。这意味着,它可以提供向后兼容性,且比 Android 平台的更新频率更高,以此确...

weixin_43506260的博客 995

Jetpack--LifeCycle、ViewModel、LiveData

Jetpack是google官方的安卓开发工具集,目的是为了标准化和加快开发效率,并且之后会持续更新 安卓开发中,google推荐使用MVVM架构,Jetpack集成了构建MVVM架构的几种工具,相比于以前的MVVM,组合使用这些工具会更加高效、简洁、安全。可以说你的安卓项目没有升级使用这套架构,那么你的架构就已经过时了 JetPack与AndroidX AndroidX命名空间中包含...

aruba的博客 281

一文搞懂Android JetPack组件原理之Lifecycle、LiveData、ViewModel与源码分析技巧

Lifecycle、LiveData和ViewModel作为AAC架构的核心,常常被用在Android业务架构中。在京东商城Android应用中,为了事件传递等个性化需求,比如ViewModel间通信、ViewModel访问Activity等等,以及为了架构的扩展性,我们封装了BaseLiveData和BaseViewModel等基础组件,也对Activity、Fragement和ViewHolder进行了封装,以JDLifecycleBaseActivity、LifecycleBaseFragment和L

1246

JetPack - - - LifeCycle、ViewModel、LiveData

Jetpack 是一个由多个库组成的套件,可帮助开发者遵循最佳做法、减少样板代码并编写可在各种 Android 版本和设备中一致运行的代码,让开发者可将精力集中于真正重要的编码工作。 JetPack的优点: 遵循最佳做法: AndroidJetpack组件采用最新的设计方法构建,具有向后兼容性,可以减少崩溃和内存泄露。消除样板代码: AndroidJetpack可以管理各种繁琐的Activity(如后台任务、导航和生命周期管理),以便您可以专注于打造出色的应用。减少不...

m0_47914176的博客 307
上一篇: Android KTX 和 Kotlin android extension对比
下一篇: kotlin : SharedPreferences 与 委托
Mars-xq
博客等级 码龄11年 3万+粉丝 1098原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址