kotlin 相关问题

Kotlin是一种由JetBrains支持的开源,静态类型编程语言。 Kotlin结合了OO和功能特性,专注于互操作性,安全性,清晰度和工具支持。它目前面向JVM和JavaScript,它是Android上官方支持的语言。

我如何使用嵌套接口来修复此错误

在代码中,您可以看到嵌套的接口。 Intellij Idea中的错误是: Kotlin:以下候选人都不适用:: 25 错误是在行中:返回整数(this.value + other.va ...

回答 1 投票 0

Dropdown菜单在扩展时不可单击

I创建了一个应用程序,并添加了一个下拉列表的组件。它曾经工作,但我无法使其再次工作。当我单击该项目时,点击不会被抓住。 代码如下: @comp ...

回答 1 投票 0

android:如何检查用户是否已登录到Play商店

使用Kotlin,我想验证用户在发送以更新应用程序之前将用户登录到PlayStore。 我使用的是凭证管理器,因为我可以找到的其他选项已弃用。

回答 1 投票 0

我试图了解我是否使用dispatcher.io而不是调度器。使用此代码

由于dispatchers.io可以扩展到64个线程,并且调度器的最大线程等于CPU内核(在我的情况下为8)

回答 1 投票 0

使用PEGA DX API插入的Android应用程序的任何来源都将不胜感激。

DXAPI本质上是动态的,并且用于实施动态UI,JetPack Compose是使用PEGA DX API进行Android开发开发的最佳方法。

回答 0 投票 0

设置3D模型的姿势在Android XRApp

在Android Xr App(以及Arcore App)中,加载具有基本交互功能的3D模型的最简单方法是实现场景查看器。您可以在场景中移动并旋转GLTF模型,如何...

回答 1 投票 0

回答 1 投票 0

将输入流放入对象中,并将它们用于流操作

fun InputStream.parser(): List<Object> { val allBytes = this.readAllBytes() val result = mutableListOf<Object>() var currentIndex = 0 for (i in allBytes.indices) { if (allBytes[i] == "\n".toByte()) { result.add(myParser.parse(allBytes, currentIndex, i)) currentIndex = i + 1 } } return result } fun consumer (input: List<Object>): Unit { for (obj in input) { // Do something with it } } 例如,解析器可以从ndjson文件中读取,消费者可以通过Internet发送该对象的一个属性。 该实现不好,它需要将整个文件加载到内存中,然后将整个对象列表加载到内存中。 我可以在没有开销的情况下做这个? 我猜测每个一代是一个新对象的地方,但是我不确定如何关闭它,因为流是用于无限流的。 我猜想这不应该是一个可觉得的,因为迭代次数会多次,这不是这种情况,一旦消耗了数据丢失, 您可以创建一个Stream.generate,这基本上是一个懒惰的列表。 IT似乎输入流包含Text,您想在流中读取线,因此我建议您在Sequence上操作。 BufferedReader 仅当请求新元素时,才能运行lambda内的代码,并且仅在下一个调用fun BufferedReader.parser() = sequence { for ((currentIndex, line) in lineSequence().withIndex()) { yield(parser.parse(line, currentIndex)) } } 时运行。 sequence { ... }将取一个yield并用consumer循环消费。 注意,此序列只能被消费once,并且您应该确保在关闭缓冲读者后不会消耗它。 您可以轻松地从Sequence<Object>使用for. 如果我的假设是错误的,而您却是一个而不是一个BufferedReader,则适用相同的原则。编写一个循环,该循环仅在每次迭代中读取所需的数据尽可能多的数据,InputStream解析结果。

回答 1 投票 0


为什么dapablestart没有显示我的图标?

IM在我的代码上遇到问题,我不知道为什么,但是如果我使用drapablestart,我的资源图标就不会显示,但是如果我使用drapableleferf,则显示出它显示(whit whit a警告时,请使用)。

回答 1 投票 0

试图渲染JTE模板时的NoclassDeffound 我有一个小型Kotlin项目,使用Javalin和JTE作为渲染器。该项目由Maven管理,以下是pom.xml。

<?xml version="1.0" encoding="UTF-8"?> <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>tech.bobdudan</groupId> <artifactId>recipes</artifactId> <version>1.0-SNAPSHOT</version> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <kotlin.code.style>official</kotlin.code.style> <kotlin.compiler.jvmTarget>21</kotlin.compiler.jvmTarget> </properties> <repositories> <repository> <id>mavenCentral</id> <url>https://repo1.maven.org/maven2/</url> </repository> </repositories> <build> <sourceDirectory>src/main/kotlin</sourceDirectory> <testSourceDirectory>src/test/kotlin</testSourceDirectory> <plugins> <plugin> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-maven-plugin</artifactId> <version>1.9.23</version> <executions> <execution> <id>compile</id> <phase>compile</phase> <goals> <goal>compile</goal> </goals> </execution> <execution> <id>test-compile</id> <phase>test-compile</phase> <goals> <goal>test-compile</goal> </goals> </execution> </executions> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.2</version> </plugin> <plugin> <artifactId>maven-failsafe-plugin</artifactId> <version>2.22.2</version> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>exec-maven-plugin</artifactId> <version>1.6.0</version> <configuration> <mainClass>tech.bobdudan.recipes.AppKt</mainClass> </configuration> </plugin> </plugins> </build> <dependencies> <dependency> <groupId>io.javalin</groupId> <artifactId>javalin</artifactId> <version>6.4.0</version> </dependency> <dependency> <groupId>io.javalin</groupId> <artifactId>javalin-rendering</artifactId> <version>6.4.0</version> </dependency> <dependency> <groupId>org.eclipse.angus</groupId> <artifactId>angus-mail</artifactId> <version>2.0.1</version> </dependency> <dependency> <groupId>gg.jte</groupId> <artifactId>jte</artifactId> <version>3.1.16</version> </dependency> <dependency> <groupId>gg.jte</groupId> <artifactId>jte-kotlin</artifactId> <version>3.1.16</version> </dependency> <dependency> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>42.7.5</version> </dependency> <dependency> <groupId>org.ktorm</groupId> <artifactId>ktorm-support-postgresql</artifactId> <version>4.1.1</version> </dependency> <dependency> <groupId>org.ktorm</groupId> <artifactId>ktorm-core</artifactId> <version>4.1.1</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <version>2.0.16</version> </dependency> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-test-junit5</artifactId> <version>1.9.23</version> <scope>test</scope> </dependency> <dependency> <groupId>org.junit.jupiter</groupId> <artifactId>junit-jupiter-engine</artifactId> <version>5.10.0</version> <scope>test</scope> </dependency> <dependency> <groupId>org.jetbrains.kotlin</groupId> <artifactId>kotlin-stdlib</artifactId> <version>1.9.23</version> </dependency> </dependencies> </project> 当我在IDE(Intellij Idea)中运行它时,我没有问题。但是,当我使用CLI中的Maven(然后是mvn clean install)中构建并运行它时,服务器启动正确并正确处理静态处理(例如images或css文件),但是在呈现时会引发以下错误JTE模板:mvn exec:java 我在这里误解了什么? 您必须使用IntellijJTE插件,该插件负责生成源,预编译等。因此,它在IDE中工作正常。 要使用CLI构建和运行,您可以为JTE.配置maven插件。 转到这可能是相关的问题。

回答 1 投票 0

如何通过编程性检测Android设备在暗模式下检测?

IM使用官方的Daynight主题制作深色/光版本,而对于可绘制的版本非常容易指向XML,它将根据已启用的内容选择正确的值或值。 我想做类似的事情,取决于主题,它将加载资产“ pricetag_light.png”或“ pricetag_dark.png”。

回答 3 投票 0

mybatis注释函数,其中uuids列表中 我有一个用户列表,我需要以给定金额减少许多黄金 Mybatis功能 @更新( ”“” 更新用户 设置金=金 - #{量}

@Update( """ UPDATE users SET gold = gold - #{amount} <where> gold >= #{amount} AND uuid IN <foreach collection="uuids" item="uuid" open="(" separator="," close=")" > #{uuid} </foreach> </where> """ ) fun reduceUsersGold( @Param("uuids") uuids: List<String>, @Param("amount") amount: Int, ): Int 这是DB的外观(简化) create TABLE IF NOT EXISTS users ( pk INT PRIMARY KEY AUTO_INCREMENT, uuid VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, gold INT NOT NULL, unique (uuid), unique (email) ); 每次我有下一个错误时,我的功能很舒服:07:59:14.340 DEBUG c.s.g.d.d.U.reduceUsersGold - ==> Preparing: UPDATE users SET gold = gold - ? <where> gold >= ? AND uuid IN <foreach collection="uuids" item="uuid" open="(" separator="," close=")" > ? </foreach> </where> ### Error updating database. Cause: org.apache.ibatis.binding.BindingException: Parameter 'uuid' not found. Available parameters are [amount, param1, uuids, param2] ### The error may exist in com/simple/games/data/dao/UserDao.java (best guess) ### The error may involve com.simple.games.data.dao.UserDao.reduceUsersGold-Inline ### The error occurred while setting parameters ### SQL: UPDATE users SET gold = gold - ? <where> gold >= ? AND uuid IN <foreach collection="uuids" item="uuid" open="(" separator="," close=")" > ? </foreach> </where> ### Cause: org.apache.ibatis.binding.BindingException: Parameter 'uuid' not found. Available parameters are [amount, param1, uuids, param2] 要在注释中使用动态标签,例如<where>或<foreach>,您需要将SQL包装在<script>.中。 因此,看起来如下:@Update( """ <script> UPDATE users SET gold = gold - #{amount} <where> gold >= #{amount} AND uuid IN <foreach collection="uuids" item="uuid" open="(" separator="," close=")" > #{uuid} </foreach> </where> </script> """ ) fun reduceUsersGold( @Param("uuids") uuids: List<String>, @Param("amount") amount: Int, ): Int the是文档: https://mybatis.org/mybatis-3/dynamic-sql.html#script

回答 1 投票 0


Inknown主机'repo.maven.apache.org'。您可能需要调整Gradle中的代理设置。 AndroidStudio

我在Android Studio中遇到了这个问题,任何人都可以帮助我

回答 2 投票 0


如果经常自动删除KSP生成的文件,该怎么办? 我正在尝试使用KSP处理注释并生成一些代码,但是我遇到了一个问题。当我修改上游代码时,下游模块的代码不会触发汇编,并且...

rootProjects module-ksp module-core implementation(project(":module-ksp")) module-other implementation(project(":module-ksp")) implementation(project(":module-core"))

回答 0 投票 0


您如何检测用户是否已使用JetPack组成的组合?

使用JetPack组成,我正在尝试创建一个自定义弹出窗口,而无需使用内置的弹出式弹出窗口可组合,因为后者不允许动画条目。我主要工作。弹出式应用...

回答 1 投票 0


最新问题
© www.soinside.com 2019 - 2025. All rights reserved.