当前位置:网站首页>使用kotlin扩展插件/依赖项简化代码(在最新版本4.0以后,此插件已被弃用,故请选择性学习,以了解为主。)
使用kotlin扩展插件/依赖项简化代码(在最新版本4.0以后,此插件已被弃用,故请选择性学习,以了解为主。)
2022-07-30 05:43:00 【¥伊人独醉】
1、添加取代findViewById(XXX)的插件;
id 'kotlin-android-extensions'
取代findViewById(XXX)
可以在kotlin代码中直接使用View上的控件id。

2、扩展插件 anko
内部添加了很多扩展函数
例如可以简化Toast的使用。

build.gradle(Module):


anko_version定义在build.gradle(project)
ext.anko_version='0.10.8'
implementation "org.jetbrains.anko:anko-common:$anko_version"activity_main2.xml

MainActivity2.kt

效果:

在最新版本4.0以后,此插件已被弃用,故请选择性学习,以了解为主。
此后出现了ViewBinding方法的使用,在后期中会更新此方法的使用。
边栏推荐
- POI工具类
- 【面经】米哈游数据开发面经
- A Spark task tuning 】 【 one day suddenly slow down how to solve
- Remember a Mailpress plugin RCE vulnerability recurrence
- Misc of CTF - other types of steganography
- Flink CDC 实现Postgres到MySQL流式加工传输案例
- npm run serve starts error npm ERR Missing script "serve"
- phpok website vulnerability exploitation analysis
- mysql is not an internal or external command, nor is it a runnable program or batch file to resolve
- jsonpath
猜你喜欢

Thread state of five

Function 函数式接口及应用

mysql不是内部或外部命令,也不是可运行的程序或批处理文件解决

MySQL - 多表查询与案例详解

"MySQL Advanced Chapter" four, the storage structure of the index

Servlet basic principles and application of common API methods

【面经】米哈游数据开发面经

3 minutes to tell you how to become a hacker | Zero foundation to hacker introductory guide, you only need to master these five skills

在不同的服务器上基于docker部署redis主从同步

MySQL-Explain详解
随机推荐
sql concat() function
FastAPI 快速入门
MySQL-Explain详解
在不同的服务器上基于docker部署redis主从同步
C#中对委托的理解和使用
The number of warehouse 】 data quality
torch distributed training
MySQL - 多表查询与案例详解
torch分布式训练
PHP-fpm
The operations engineer interview experience
Usage of exists in sql
awd --waf deployment
MySQL存储引擎
[Ten years of network security engineers finishing] - 100 penetration testing tools introduction
线程的5种状态
DVWA安装教程(懂你的不懂·详细)
C# WPF中监听窗口大小变化事件
TypeError The view function did not return a valid response. The function either returned None 的解决
uncategorized SQLException; SQL state [null]; error code [0]; sql injection violation, syntax error