ViewBinding 与 Kotlin 委托双剑合璧

ViewBinding的原理(二) 上次主要总结了一下ViewBinding的使用方式,基本涵盖了常用的场景,后续遇到其他场景我会陆续的补充。 这次打算总结一下实现的原理,保证自己知其所以然。 1、如何实现view绑定 通过代码来分析: 生成的文件代码例子如下: public final class ActivityViewBindingTestBinding implements ViewBinding { @NonNull private final LinearLayout rootView; @NonNull p 阅读详情

前言

  • ViewBinding 是 Android Gradle Plugin 3.6 中新增的特性,用于更加轻量地实现视图绑定(视图与变量的绑定),可以理解为轻量版本的 DataBinding;
  • 在这篇文章里,我将总结 ViewBinding 使用方法 & 原理,如果能帮上忙,请务必点赞加关注,这真的对我非常重要。

目录


前置知识

这篇文章的内容会涉及以下前置 / 相关知识,贴心的我都帮你准备好了,请享用~


1. 概述

  • ViewBinding 解决了什么问题: ViewBinding 替代 findViewById,更优雅地实现视图交互;

  • ViewBinding 的实现原理: Android Gradle 插件会为每个 XML 布局文件创建一个绑定类,绑定类中包含布局文件中每个定义了android:id属性的 View 引用。假设布局文件为fragment_test.xml,则生成绑定类FragmentTestBinding.java;

  • 所有 XML 布局文件都生成 Java 类,会不会导致包体积瞬间增大? 未使用的类会在混淆时被压缩。


2. ViewBinding 与其他视图绑定方案对比

在 ViewBinding 之前,业界已经有过几种视图绑定方案了,想必你也用过。那么,ViewBinding 作为后起之秀就一定比前者香吗,我带你分析下。

角度findViewByIdButterKnifeKotlin SyntheticsDataBindingViewBinding❓
简洁性✖✖✔✔✔❓
编译期检查✖✖✖✔✔❓
编译速度✔✖✔✖✔❓
支持 Kotlin & Java✔✔✖✔✔❓
收敛模板代码✖✖✔✖✖❓
  • 简洁性: findViewById 和 ButterKnife 需要在代码中声明很多变量,其他几种方案代码简洁读较好;

  • 编译检查: 编译期间主要有两个方面的检查:类型检查 + 只能访问当前布局中的 id。findViewById、ButterKnife 和 Kotlin Synthetics 在这方面表现较差;

  • 编译速度: findViewById 的编译速度是最快的,而 ButterKnife 和 DataBinding 中存在注解处理,编译速度略逊色于 Kotlin Synthetics 和 ViewBinding;

  • 支持 Kotlin & Java: Kotlin Synthetics 只支持 Kotlin 语言;

  • 收敛模板代码: 基本上每种方案都带有一定量的模板代码,只有 Kotlin Synthetics 的模板代码是较少的。

可以看到,并没有一种绝对优势的方法,但越往后整体的效果是有提升的。另外,❓是什么呢?

3. ViewBinding 怎么用?

这一节我们来介绍 ViewBinding 的使用方法,内容不多。

注意:ViewBinding 要求在 Android Gradle Plugin 版本在至少在 3.6 以上。

3.1 添加配置

视图绑定功能按模块级别启用,启用的模块需要在模块级 build.gralde 中添加配置。例如:

build.gradle

android {
    ...
    viewBinding {
        enabled = true
    }
}

对于不需要生成绑定类的布局文件,可以在根节点声明tools:viewBindingIgnore="true"。例如:

<LinearLayout
    ...
    tools:viewBindingIgnore="true" >
    ...
</LinearLayout>

3.2 创建绑定类

有三个创建绑定类的 API:

fun <T> bind(view : View) : T

fun <T> inflate(inflater : LayoutInflater) : T

fun <T> inflate(inflater : LayoutInflater, parent : ViewGroup?, attachToParent : Boolean) : T
  • 1、在 Activity 中使用

MainActivity.kt

class TestActivity: AppCompatActivity(R.layout.activity_test) {

    private lateinit var binding: ActivityTestBinding

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        binding = ActivityTestBinding.inflate(layoutInflater)
        setContentView(binding.root)
        binding.tvDisplay.text = "Hello World."
    }
}   
  • 2、在 Fragment 中使用

TestFragment.kt

class TestFragment : Fragment(R.layout.fragment_test) {

    private var _binding: FragmentTestBinding? = null
    private val binding get() = _binding!!

    override fun onViewCreated(root: View, savedInstanceState: Bundle?) {
        _binding = FragmentTestBinding.bind(root)

        binding.tvDisplay.text = "Hello World."
    }

    override fun onDestroyView() {
        super.onDestroyView()

        _binding = null
    }
}

3.3 避免内存泄露

这里有一个隐藏的内存泄露问题,你需要理解清楚(严格来说这并不是 ViewBinding 的问题,即使你采用其它视图绑定方案也要考虑这个问题)。

问题:为什么 Fragment#onDestroyView() 里需要置空绑定类对象,而 Activity 里不需要? 答:Activity 实例和 Activity 视图的生命周期是同步的,而 Fragment 实例和 Fragment 视图的生命周期并不是完全同步的,因此需要在 Fragment 视图销毁时,手动回收绑定类对象,否则造成内存泄露。例如:detach Fragment,或者 remove Fragment 并且事务进入返回栈,此时 Fragment 视图销毁但 Fragment 实例存在。关于 Fragment 生命周期和事务在我之前的一篇文章里讨论过:Android | Fragment 核心原理 & 面试题 (AndroidX 版本)

总之,在视图销毁但是控制类对象实例还存活的时机,你就需要手动回收绑定类对象,否则造成内存泄露。

3.4 ViewBinding 绑定类源码

反编译如下:

public final class ActivityTestBinding implements ViewBinding {
    private final ConstraintLayout rootView;
    public final TextView tvDisplay;
  
    private ActivityTestBinding (ConstraintLayout paramConstraintLayout1, TextView paramTextView)
        this.rootView = paramConstraintLayout1;
        this.tvDisplay = paramTextView;
    }
  
    public static ActivityTestBinding bind(View paramView) {
        TextView localTextView = (TextView)paramView.findViewById(2131165363);
        if (localTextView != null) {
            return new ActivityMainBinding((ConstraintLayout)paramView, localTextView);
        }else {
          paramView = "tvDisplay";
        }
        throw new NullPointerException("Missing required view with ID: ".concat(paramView));
    }
  
    public static ActivityMainBinding inflate(LayoutInflater paramLayoutInflater) {
        return inflate(paramLayoutInflater, null, false);
    }
  
    public static ActivityMainBinding inflate(LayoutInflater paramLayoutInflater, ViewGroup paramViewGroup, boolean paramBoolean) {
        paramLayoutInflater = paramLayoutInflater.inflate(2131361821, paramViewGroup, false);
        if (paramBoolean) {
            paramViewGroup.addView(paramLayoutInflater);
        }
        return bind(paramLayoutInflater);
    }
  
    public ConstraintLayout getRoot() {
        return this.rootView;
    }
}

4. ViewBinding 与 Kotlin 委托双剑合璧

到这里,ViewBinding 的使用教程已经说完了。但是回过头看,有没有发现一些局限性呢?

  • 1、创建和回收 ViewBinding 对象需要重复编写样板代码,特别是在 Fragment 中使用的案例;
  • 2、binding 属性是可空的,也是可变的,使用起来不方便。

那么,有没有可优化的方案呢?我们想起了 Kotlin 属性委托,关于 Kotlin 委托机制在我之前的一篇文章里讨论过:Kotlin | 委托机制 & 原理。如果你还不太了解 Kotlin 委托,下面的内容对你会有些难度。

下面,我将带你一步步封装 ViewBinding 属性委托工具:

4.1 ViewBinding + Kotlin 委托 1.0

首先,我们梳理一下我们要委托的内容与需求,以及相应的解决办法:

需求解决办法
需要委托 ViewBinding#bind() 的调用反射
需要委托 binding = null 的调用监听 Fragment 视图生命周期
期望 binding 属性声明为非空不可变变量ReadOnlyProperty<F, V>

FragmentViewBindingPropertyV1.kt

private const val TAG = "ViewBindingProperty"

public inline fun <reified V : ViewBinding> viewBindingV1() = viewBindingV1(V::class.java)

public inline fun <reified T : ViewBinding> viewBindingV1(clazz: Class<T>): FragmentViewBindingPropertyV1<Fragment, T> {
    val bindMethod = clazz.getMethod("bind", View::class.java)
    return FragmentViewBindingPropertyV1 {
        bindMethod(null, it.requireView()) as T
    }
}

/**
 * @param viewBinder 创建绑定类对象
 */
class FragmentViewBindingPropertyV1<in F : Fragment, out V : ViewBinding>(
    private val viewBinder: (F) -> V
) : ReadOnlyProperty<F, V> {

    private var viewBinding: V? = null

    @MainThread
    override fun getValue(thisRef: F, property: KProperty<*>): V {
        // 已经绑定,直接返回
        viewBinding?.let { return it }

        // Use viewLifecycleOwner.lifecycle other than lifecycle
        val lifecycle = thisRef.viewLifecycleOwner.lifecycle
        val viewBinding = viewBinder(thisRef)
        if (lifecycle.currentState == Lifecycle.State.DESTROYED) {
            Log.w(
                TAG, "Access to viewBinding after Lifecycle is destroyed or hasn't created yet. " +
                        "The instance of viewBinding will be not cached."
            )
            // We can access to ViewBinding after Fragment.onDestroyView(), but don't save it to prevent memory leak
        } else {
            lifecycle.addObserver(ClearOnDestroyLifecycleObserver())
            this.viewBinding = viewBinding
        }
        return viewBinding
    }

    @MainThread
    fun clear() {
        viewBinding = null
    }

    private inner class ClearOnDestroyLifecycleObserver : LifecycleObserver {

        private val mainHandler = Handler(Looper.getMainLooper())

        @MainThread
        @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
        fun onDestroy(owner: LifecycleOwner) {
            owner.lifecycle.removeObserver(this)
            mainHandler.post { clear() }
        }
    }
}

使用方法:

class TestFragment : Fragment(R.layout.fragment_test) {

    private val binding : FragmentTestBinding by viewBindingV1()

    override fun onViewCreated(root: View, savedInstanceState: Bundle?) {
        binding.tvDisplay.text = "Hello World."
    }
}

干净清爽!前面提出的三个需求也都实现了,现在我为你解答细节:

  • 问题 1、为什么可以使用 V::class.java,不是泛型擦除了吗? 利用了 Kotlin 内敛函数 + 实化类型参数,编译后函数体整体被复制到调用处,V::class.java 其实是 FragmentTestBinding::class.java。具体分析见:Java | 关于泛型能问的都在这里了(含Kotlin)

  • 问题 2、ReadOnlyProperty<F, V> 是什么? ReadOnlyProperty 是不可变属性代理,通过 getValue(...) 方法实现委托行为。第一个类型参数 F 是属性所有者,第二个参数 V 是属性类型,因为我们在 Fragment 中定义属性,属性类型为 ViewBinding,所谓定义类型参数为 <in F : Fragment, out V : ViewBinding>;

  • 问题 3、解释下 getValue(...) 方法? 直接看注释:

@MainThread
override fun getValue(thisRef: F, property: KProperty<*>): V {
    1、viewBinding 不为空说明已经绑定,直接返回
    viewBinding?.let { return it }

    2、Fragment 视图的生命周期
    val lifecycle = thisRef.viewLifecycleOwner.lifecycle

    3、实例化绑定类对象
    val viewBinding = viewBinder(thisRef)

    if (lifecycle.currentState == Lifecycle.State.DESTROYED) {
        4.1 如果视图生命周期为 DESTROYED,说明视图被销毁,此时不缓存绑定类对象(避免内存泄漏)
    } else {
        4.2 定义视图生命周期监听者
        lifecycle.addObserver(ClearOnDestroyLifecycleObserver())
        4.3 缓存绑定类对象
        this.viewBinding = viewBinding
    }
    return viewBinding
}
  • 为什么 onDestroy() 要采用 Handler#post(Message) 完成? 因为 Fragment#viewLifecycleOwner 通知生命周期事件 ON_DESTROY 的时机在 Fragment#onDestryoView 之前。

4.2 ViewBinding + Kotlin 委托 2.0

1.0 版本使用了反射,真的一定要反射吗?反射调用 bind 函数的目的就是获得一个 ViewBinding 绑定类对象,或许我们可以试试把创建对象的行为交给外部去定义,类似这样:

inline fun <F : Fragment, V : ViewBinding> viewBindingV2(
    crossinline viewBinder: (View) -> V,
    crossinline viewProvider: (F) -> View = Fragment::requireView
) = FragmentViewBindingPropertyV2 { fragment: F ->
    viewBinder(viewProvider(fragment))
}

class FragmentViewBindingPropertyV2<in F : Fragment, out V : ViewBinding>(
    private val viewBinder: (F) -> V
) : ReadOnlyProperty<F, V> {
    相同 ...
}

使用方法:

class TestFragment : Fragment(R.layout.fragment_test) {

    private val binding by viewBindingV2(FragmentTestBinding::bind)

    override fun onViewCreated(root: View, savedInstanceState: Bundle?) {
        binding.tvDisplay.text = "Hello World."
    }
}

干净清爽!不使用反射也可以实现,现在我为你解答细节:

  • 问题 4、(View) -> V 是什么? Kotlin 高阶函数,可以把 lambda 表达式直接作为参数传递,其中 View 是函数参数,而 T 是函数返回值。lambda 表达式本质上是 「可以作为值传递的代码块」。在老版本 Java 中,传递代码块需要使用匿名内部类实现,而使用 甚至连函数声明都不需要,可以直接传递代码块作为函数值;

  • 问题 5、Fragment::requireView 是什么? 把函数 requireView() 作为参数传递。Fragment#requireView() 返回 Fragment 根视图,在 onCreateView() 之前调用 requireView() 会抛出异常;

  • 问题 6、FragmentTestBinding::bind 是什么? 把函数 bind() 作为参数传递,bind 函数的参数为 View,返回值为 ViewBinding,与函数声明 (View) -> V 匹配。

4.3 ViewBinding + Kotlin 委托 最终版

2.0 版本已经完成了针对 Fragment 的属性代理,但是实际场景中只会在 Fragment 中使用 ViewBinding 吗?显然并不是,我们还有其他一些场景:

  • Activity
  • Fragment
  • DialogFragment
  • ViewGroup
  • RecyclerView.ViewHolder

所以,我们有必要将委托工具适当封装得更通用些,完整代码和演示工程你可以直接下载查看:下载路径,这里只展示部分核心代码如下:

@JvmName("viewBindingActivity")
inline fun <A : ComponentActivity, V : ViewBinding> viewBinding(
    crossinline viewBinder: (View) -> V,
    crossinline viewProvider: (A) -> View = ::findRootView
): ViewBindingProperty<A, V> = ActivityViewBindingProperty { activity: A ->
    viewBinder(viewProvider(activity))
}

@JvmName("viewBindingActivity")
inline fun <A : ComponentActivity, V : ViewBinding> viewBinding(
    crossinline viewBinder: (View) -> V,
    @IdRes viewBindingRootId: Int
): ViewBindingProperty<A, V> = ActivityViewBindingProperty { activity: A ->
    viewBinder(activity.requireViewByIdCompat(viewBindingRootId))
}

// -------------------------------------------------------------------------------------
// ViewBindingProperty for Fragment
// -------------------------------------------------------------------------------------

@Suppress("UNCHECKED_CAST")
@JvmName("viewBindingFragment")
inline fun <F : Fragment, V : ViewBinding> Fragment.viewBinding(
    crossinline viewBinder: (View) -> V,
    crossinline viewProvider: (F) -> View = Fragment::requireView
): ViewBindingProperty<F, V> = when (this) {
    is DialogFragment -> DialogFragmentViewBindingProperty { fragment: F ->
        viewBinder(viewProvider(fragment))
    } as ViewBindingProperty<F, V>
    else -> FragmentViewBindingProperty { fragment: F ->
        viewBinder(viewProvider(fragment))
    }
}

@Suppress("UNCHECKED_CAST")
@JvmName("viewBindingFragment")
inline fun <F : Fragment, V : ViewBinding> Fragment.viewBinding(
    crossinline viewBinder: (View) -> V,
    @IdRes viewBindingRootId: Int
): ViewBindingProperty<F, V> = when (this) {
    is DialogFragment -> viewBinding(viewBinder) { fragment: DialogFragment ->
        fragment.getRootView(viewBindingRootId)
    } as ViewBindingProperty<F, V>
    else -> viewBinding(viewBinder) { fragment: F ->
        fragment.requireView().requireViewByIdCompat(viewBindingRootId)
    }
}

// -------------------------------------------------------------------------------------
// ViewBindingProperty
// -------------------------------------------------------------------------------------

private const val TAG = "ViewBindingProperty"

interface ViewBindingProperty<in R : Any, out V : ViewBinding> : ReadOnlyProperty<R, V> {
    @MainThread
    fun clear()
}

abstract class LifecycleViewBindingProperty<in R : Any, out V : ViewBinding>(
    private val viewBinder: (R) -> V
) : ViewBindingProperty<R, V> {

    private var viewBinding: V? = null

    protected abstract fun getLifecycleOwner(thisRef: R): LifecycleOwner

    @MainThread
    override fun getValue(thisRef: R, property: KProperty<*>): V {
        // Already bound
        viewBinding?.let { return it }

        val lifecycle = getLifecycleOwner(thisRef).lifecycle
        val viewBinding = viewBinder(thisRef)
        if (lifecycle.currentState == Lifecycle.State.DESTROYED) {
            Log.w(
                TAG, "Access to viewBinding after Lifecycle is destroyed or hasn'V created yet. " +
                        "The instance of viewBinding will be not cached."
            )
            // We can access to ViewBinding after Fragment.onDestroyView(), but don'V save it to prevent memory leak
        } else {
            lifecycle.addObserver(ClearOnDestroyLifecycleObserver(this))
            this.viewBinding = viewBinding
        }
        return viewBinding
    }

    @MainThread
    override fun clear() {
        viewBinding = null
    }

    private class ClearOnDestroyLifecycleObserver(
        private val property: LifecycleViewBindingProperty<*, *>
    ) : LifecycleObserver {

        private companion object {
            private val mainHandler = Handler(Looper.getMainLooper())
        }

        @MainThread
        @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
        fun onDestroy(owner: LifecycleOwner) {
            mainHandler.post { property.clear() }
        }
    }
}

class FragmentViewBindingProperty<in F : Fragment, out V : ViewBinding>(
    viewBinder: (F) -> V
) : LifecycleViewBindingProperty<F, V>(viewBinder) {

    override fun getLifecycleOwner(thisRef: F): LifecycleOwner {
        try {
            return thisRef.viewLifecycleOwner
        } catch (ignored: IllegalStateException) {
            error("Fragment doesn't have view associated with it or the view has been destroyed")
        }
    }
}

class DialogFragmentViewBindingProperty<in F : DialogFragment, out V : ViewBinding>(
    viewBinder: (F) -> V
) : LifecycleViewBindingProperty<F, V>(viewBinder) {

    override fun getLifecycleOwner(thisRef: F): LifecycleOwner {
        return if (thisRef.showsDialog) {
            thisRef
        } else {
            try {
                thisRef.viewLifecycleOwner
            } catch (ignored: IllegalStateException) {
                error("Fragment doesn't have view associated with it or the view has been destroyed")
            }
        }
    }
}

5. 总结

ViewBinding 是一个轻量级的视图绑定方案,Android Gradle 插件会为每个 XML 布局文件创建一个绑定类。在 Fragment 中使用 ViewBinding 需要注意在 Fragment#onDestroyView() 里置空绑定类对象避免内存泄漏。但这会带来很多重复编写样板代码,使用属性委托可以收敛模板代码,保证调用方代码干净清爽。

角度findViewByIdButterKnifeKotlin SyntheticsDataBindingViewBindingViewBindingProperty
简洁性✖✖✔✔✔✔
编译期检查✖✖✖✔✔✔
编译速度✔✖✔✖✔✔
支持 Kotlin & Java✔✔✖✔✔✔
收敛模板代码✖✖✔✖✖✔

参考资料

 

作者:彭丑丑
链接:https://juejin.cn/post/6960914424865488932
来源:掘金
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

ViewBinding - Jetpack 视图绑定委托封装及使用示例 通过视图绑定功能,您可以更轻松地编写可与视图交互的代码。在模块中启用视图绑定之后,系统会为该模块中的每个 XML 布局文件生成一个绑定类。绑定类的实例包含对在相应布局中具有 ID 的所有视图的直接引用。 在大多数情况下,视图绑定会替代findViewById。 阅读详情

相关推荐

组件化之路 - ViewBinding基类封装

既然已经掌握了 ViewBinding ,那么接下来肯定是要集成到项目中跑起来咯~ 使用View Binding 写的基类 通过反射的方式(这种方式不推荐使用,会有混淆问题) //Java public class BaseActivity<T extends ViewBinding> extends AppCompatActivity { protected T viewBinding; @Override protected void onCreate(Bundle s.

Android、前端、小程序、后端 8148

Android架构组件____视图绑定

Android架构组件____视图绑定 Android架构____视图的绑定视图绑定 提示:写完文章后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录Android架构组件____视图绑定前言一、视图绑定二、使用步骤1.引入库2.忽略某个布局文件2.忽略某个布局文件总结 前言 相信大多数的80,90后都使用过findViewById吧,尤其是项目全局变量及其多时强迫症估计受不了。当然了一堆的的全局变量也导致了很多问题1. 因视图 ID 无效而引发 Null 指针异常的风险.忘记findvie

Stay hungry, stay foolish!! 714

RAGFlow源码解析-2、从源码构架ragflow v0.25.0镜像

本文详细记录了从零开始构建自定义RAGFlow镜像lt/ragflow:0.25.0的全过程。首先介绍了环境准备,包括检查Node.js、Docker版本和项目结构。然后详细说明了构建步骤:编译前端、创建自定义Dockerfile、构建镜像和验证。接着讲解了docker-compose配置修改要点,包括网络定义、MySQL依赖处理等。最后总结了部署过程中遇到的五个关键问题及解决方案,包括networks未定义、MySQL服务依赖、tiktoken文件缺失、数据库配置错误和端口映射问题。通过完整的操作流程和问

liutao841204的专栏 372

ViewBinding与DataBinding(视图绑定与数据双向绑定)

前言:心中纵是有所盼 严寒没有减 风很冷 我的手已渐蓝 前言 控件查找对于Android开发来说也是一部血泪史,一直为更有效的方案进行了多种方案的研究和探讨。`findViewById()` 过于繁琐,强制转换不安全;`butterkniife` 会存在众多臃肿的全局

https://juejin.cn/user/1654096907477549/posts 4260

vivado安装空间与依赖要求:入门须知要点

准备安装Vivado时,需重点关注系统空间和依赖环境的配置。结合vivado安装教程,详细说明最低磁盘要求、内存配置及操作系统兼容性,帮助新手快速搭建开发环境,避免常见安装失败问题。

weixin_34725745的博客 1600

海思ISP调优实战:从实验室到真实场景的IPC相机图像质量优化指南

本文深入探讨海思ISP调优在IPC相机图像质量优化中的实战应用,从实验室标定到真实场景部署的全链路调优方法。重点解决光照动态范围、色温变化和噪声特性等核心问题,提供AE权重表配置、CCM标定、3DNR时域滤波等关键技术方案,帮助实现从理论到实践的图像质量提升。

s3t4u的博客 760

Android _ ViewBinding 与 Kotlin 委托双剑合璧

{= null!) {

2401_83916204的博客 1065

ATM火控电容改造实战:提升速凌无刷电机动力与系统稳定性

在嵌入式系统与电机驱动领域,电源完整性是保障电路稳定运行的核心基础。其核心原理在于通过合理的电容网络设计,为负载提供瞬时大电流并滤除高频噪声,从而维持电压稳定。这项技术的核心价值在于能显著提升系统的动态响应能力与可靠性,避免因电压跌落导致微控制器复位或功率器件过应力。典型的应用场景包括无人机电调、机器人关节驱动以及各类需要快速响应的伺服系统。本文聚焦于水弹发射器ATM火控系统的硬件迭代,通过详解电容的选型、布局与焊接流程,特别是针对速凌五代无刷电机的高启动电流特性,系统性地阐述了如何通过强化电源储能与芯片去

weixin_33868027的博客 571

Android _ ViewBinding 与 Kotlin 委托双剑合璧(1)

最后我想说:对于程序员来说,要学习的知识内容、技术有太多太多,要想不被环境淘汰就只有不断提升自己,

bfhye16552的博客 691

深度学习模型设计的方法和技巧

设计神经网络模型是一个迭代的过程,需要不断试验和调整各个组成部分,以达到最佳性能。同时,遵循良好的工程实践,如模块化设计、版本控制、文档记录等,也是成功的关键。

xw555666的博客 4039

华为服务器RAID配置避坑指南:如何通过iBMC快速识别阵列卡型号并完成初始化

本文详细解析华为服务器RAID配置全流程,重点介绍通过iBMC快速识别阵列卡型号、硬盘健康诊断及RAID级别选择的场景化策略。提供从iBMC登录到缓存策略调优的实战技巧,帮助工程师避免常见配置陷阱,提升服务器存储系统性能和稳定性。

weixin_28475533的博客 503

Android _ ViewBinding 与 Kotlin 委托双剑合璧(2)

最后,如果大伙有什么好的学习方法或建议欢迎大家在评论中积极留言哈,希望大家能够共同学习、共同努力、共同进步。

2401_84149339的博客 985

Allegro PCB设计小技巧:如何用Shift键快速平移复制走线和过孔?

本文深入解析了Allegro PCB设计中利用Shift键进行平移复制的核心技巧。通过对比传统复制粘贴流程,详细演示了如何高效、精准地批量复制走线和过孔,尤其适用于创建等间距电源总线、过孔阵列等场景,能显著提升PCB设计效率与准确性。

pz89012345的博客 569
上一篇: 补齐Android技能树 - 从害怕到玩转Android代码混淆
下一篇: Kotlin | 委托机制 & 原理 & 应用
锐湃
博客等级 码龄15年 736粉丝 170原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值