![](https://img-blog.csdnimg.cn/20201014180756738.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
kotlin
kotlin的使用
倒骑驴走着瞧
不积跬步无以至千里
展开
-
kotlin方式集成Arouter遇到问题
按照Arouter git 官方的kotlin方式配置 遇到如下问题Execution failed for task ':app:checkDebugDuplicateClasses'.> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable > Duplicate class android.support.v4.app.INotifica原创 2021-09-18 13:14:49 · 466 阅读 · 0 评论 -
Kotlin 高阶函数
如果一个函数接收另一个函数作为参数,或者返回值的类型是另一个函数,那么该函数就称为高阶函数/*** 函数类型* (Int,Int) -> Int* 左边是函数接收的参数,多个参数用逗号隔开,如果没有参数就()* 右边是返回类型,如果没有返回值就用Unit,大致相当于Java中的void*//*** 加法函数*/fun plus(num1: Int, num2: Int): Int { return num1 + num2}/*** 减法函数*/fun minus原创 2021-09-09 13:59:15 · 154 阅读 · 0 评论 -
kotlin lateinit
有的小伙伴刚开始写 Kotlin 代码的时候,会把写 Java 代码的习惯也带过来,比如这样:class Demo { var value: String fun printValue() { println(value) }}当然,这样写的后果就是一个编译错误:Error:(2, 5) Kotlin: Property must be initialized or be abstract这时候,有的小伙伴看到了 lateinit 修饰符lateinit var v转载 2021-09-08 09:51:29 · 1015 阅读 · 0 评论 -
android studio 老项目支持kotlin
项目根目录下的build.gradle中添加kotlin编译插件app中build.gradle中使用kotlin插件添加标准库依赖原创 2021-07-13 20:58:55 · 1041 阅读 · 2 评论 -
kotlin点击事件
kotlin几种设置点击事件方式1.匿名内部类2.实现View.OnClickListener接口的onClick方法3.控件添加onClick属性,对应activity或者fragment中添加对应方法布局文件 <TextView android:id="@+id/test" android:layout_width="match_parent" android:layout_height="48dp" android:gra原创 2020-08-26 09:40:07 · 4754 阅读 · 0 评论 -
Kotlin Android Extensions使用指南
Kotlin Android Extensions是Kotlin团队开发的一个插件,目的是让我们在开发过程中更少的编写代码。目前包括了视图绑定的功能。几种绑定视图方式对比**xml文件如下<?xml version="1.0" encoding="utf-8"?><LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_height=转载 2020-08-25 18:02:47 · 2797 阅读 · 1 评论