kotlin

Gradle 的下载安装配置以及创建第一个Gradle 项目

老子叫甜甜 提交于 2021-02-15 20:25:54
1. 什么是Gradle? Gradle是一个开源的构建自动化工具,专注于灵活性和性能。 Gradle构建脚本使用Groovy或Kotlin DSL编写。 阅读Gradle功能,了解Gradle的功能。 高度可定制 - Gradle以一种可以以最基本的方式定制和扩展的方式建模。 快速 - Gradle通过重用先前执行的输出,仅处理已更改的输入以及并行执行任务来快速完成任务。 功能强大 - Gradle是Android的官方构建工具,并支持许多流行的语言和技术。 2. Gradle 的下载和安装 我们可以安装Gradle 构建工具在Linux,MacOS ,windows 操作系统上,这个文档覆盖了使用包管理器像SDKMAN!,Homebrew,或者Scoop的安装方法。 使用Gradle Wrapper是升级Gradle的推荐方法 我们可以找到所有的发布版本在 发布页面 1.1 Gradle 必要条件 Gradle 可以运行在大多数的操作系统中,但是需要JDK 或者JRE 8 以上版本 检查方法,打开操作系统命令行终端,输入命令 java -version 执行成功如下所示: 注意: Gradle附带了自己的Groovy库,因此不需要安装Groovy。 Gradle会忽略任何现有的Groovy安装。 Gradle 会在path环境变量中招JDK 安装路径,我们可以设置JAVA

How to Pass custom object via intent in kotlin

旧街凉风 提交于 2021-02-15 09:14:29
问题 fun launchNextScreen(context: Context, people: People): Intent { val intent = Intent(context, NextScreenActivity::class.java) intent.putExtra(EXTRA_PEOPLE, (Parcelable) people) //intent.putExtra(EXTRA_PEOPLE, people as Parcelable) //intent.putExtra(EXTRA_PEOPLE, people) // tried above all three ways return intent } I tried the above code to pass an instance of the People class via intent using kotlin, but I am getting an error. What am I doing wrong? 回答1: First, make sure the People class

How to Pass custom object via intent in kotlin

浪子不回头ぞ 提交于 2021-02-15 09:09:34
问题 fun launchNextScreen(context: Context, people: People): Intent { val intent = Intent(context, NextScreenActivity::class.java) intent.putExtra(EXTRA_PEOPLE, (Parcelable) people) //intent.putExtra(EXTRA_PEOPLE, people as Parcelable) //intent.putExtra(EXTRA_PEOPLE, people) // tried above all three ways return intent } I tried the above code to pass an instance of the People class via intent using kotlin, but I am getting an error. What am I doing wrong? 回答1: First, make sure the People class

How to Pass custom object via intent in kotlin

守給你的承諾、 提交于 2021-02-15 09:07:31
问题 fun launchNextScreen(context: Context, people: People): Intent { val intent = Intent(context, NextScreenActivity::class.java) intent.putExtra(EXTRA_PEOPLE, (Parcelable) people) //intent.putExtra(EXTRA_PEOPLE, people as Parcelable) //intent.putExtra(EXTRA_PEOPLE, people) // tried above all three ways return intent } I tried the above code to pass an instance of the People class via intent using kotlin, but I am getting an error. What am I doing wrong? 回答1: First, make sure the People class

Android 11 Meetup 上海站!来了!

自作多情 提交于 2021-02-14 12:01:00
6月初, 谷歌发布了 Android 11 Beta 版 ,为开发者们带来了众多重磅更新。 这些更新包括系统内有关隐私方面的变更、键盘、聊天体验、5G 技术等优化,以及方便跟踪崩溃的 API。工具方面,包含了 Jetpack 的更新,例如工具包与 Kotlin 协程的整合、Compose 的最新进展、Android Studio 构建性能等改进,以及 Play Console 的全新改版。 更新要点: Android 11 Beta 版正式发布!以及众多面向开发者的重磅更新 Android 11 Beta 版 官网: https://developer.android.google.cn/android11 7月4日 中国第一场 Android 11 Meetup 谷歌将在全球举办一系列线上活动。7月4 日,中国的第一场 Android 11 Meetup 落在上海 ,由 GDG Shanghai 主办。我们会和大家一起探讨 Android 11 的新内容、应用兼容性,以及现代化 Android 开发的基本知识和最佳实践。让我们用技术人的热忱和独特的方式为时下的困境,注入一股技术正能量! 本次上海站活动将分为线上、线下同时进行: 线上活动信息 时间:2020 年 7 月 4 日 13:00 - 17:00 B站上海GDG直播间: https://live.bilibili.com

Android 11 Meetup 线上直播倒计时五天!

时间秒杀一切 提交于 2021-02-14 11:40:08
6月初, 谷歌发布了 Android 11 Beta 版 ,为开发者们带来了众多重磅更新。 更新要点: Android 11 Beta 版正式发布!以及众多面向开发者的重磅更新 Android 11 Beta 版 官网: https://developer.android.google.cn/android11 7月4 日,带着技术人的热忱,中国的第一场 Android 11 Meetup 将落在上海 ,由 GDG Shanghai 主办。我们会和大家一起探讨 Android 11 的新内容、应用兼容性,以及现代化 Android 开发的基本知识和最佳实践。 线上活动信息 时间:2020 年 7 月 4 日 13:00 - 16:00 B站上海GDG直播间: https://live.bilibili.com/21917305 报名:扫码直接观看 提前申请加入我们的微信交流群 获取活动资料、互动答疑、抽取礼包! 请使用微信扫码申请加入 微信群里我们会发布一些活动相关的信息,提前发送活动资料,活动后答疑,同时活动当天还会在微信群中抽取 GDG 活动大礼包! 万众瞩目的嘉宾阵容 这次我们有幸邀请到谷歌的安卓技术推广中国区负责人钟辉,安卓技术推广工程师 Fung Lam,以及国内知名的安卓开发工程师 郭霖,一起为大家带来精彩纷呈的技术分享。 详细的日程安排上了 13:00 - 13:30

程序员必备的网站推荐

こ雲淡風輕ζ 提交于 2021-02-13 23:44:17
CSDN: https://blog.csdn.net/chk218/article/details/83620744 1 一、开源代码托管平台 GitHub(https://github.com) gitHub是一个面向开源及私有软件项目的托管平台,因为只支持git 作为唯一的版本库格式进行托管,故名gitHub。 gitHub于2008年4月10日正式上线,除了git代码仓库托管及基本的 Web管理界面以外,还提供了订阅、讨论组、文本渲染、在线文件编辑器、协作图谱(报表)、代码片段分享(Gist)等功能。目前,其注册用户已经超过350万,托管版本数量也是非常之多,其中不乏知名开源项目 Ruby on Rails、jQuery、python 等。 2018年6月4日,微软宣布,通过75亿美元的股票交易收购代码托管平台GitHub。 码云(https://gitee.com) 码云专为开发者提供稳定、高效、安全的云端软件开发协作平台 无论是个人、团队、或是企业,都能够用码云实现代码托管、项目管理、协作开发 2 二、编程学习网站 菜鸟教程(http://www.runoob.com) 菜鸟教程的 Slogan 为:学的不仅是技术,更是梦想! 菜鸟教程域名为 runoob.com, runoob 为 Running Noob 的缩写,意为:奔跑吧!菜鸟。 菜鸟教程包括了HTML、CSS

Unresolved reference - activity does not recognize synthetic imports in android studio v4

五迷三道 提交于 2021-02-13 05:40:42
问题 last night I noticed I'm not able to change the attributes of elements in the layout from my main activity so I built a new project and I had the same problem there too. I could not find out what was wrong with my android studio so I'd appreciate it if someone with the same problem helps me out. as you see in the picture when I call a defined view from the layout in my activity its not recognized the error will be: Unresolved reference: txtHello 回答1: Kotlin Synthetic imports not working ?

Kotlin avoid smart cast for null check

こ雲淡風輕ζ 提交于 2021-02-11 18:19:49
问题 So I'm trying to reduce this code and avoid the smart cast hint from IDE. The idea is I have a nullable variable of type T and I want to either map it to R or I just get R from a supplier in case the variable is null . I've tried different approaches and came up with this one. Still it gives me the smart cast hint. fun <T, R> T?.func(mapper: (T) -> R, supplier: () -> R): R = when(this) { null -> supplier() else -> mapper(this) // smart cast } But I don't like the need for wrapping one of the

Kotlin avoid smart cast for null check

喜你入骨 提交于 2021-02-11 18:18:19
问题 So I'm trying to reduce this code and avoid the smart cast hint from IDE. The idea is I have a nullable variable of type T and I want to either map it to R or I just get R from a supplier in case the variable is null . I've tried different approaches and came up with this one. Still it gives me the smart cast hint. fun <T, R> T?.func(mapper: (T) -> R, supplier: () -> R): R = when(this) { null -> supplier() else -> mapper(this) // smart cast } But I don't like the need for wrapping one of the