草庐IT

kotlin.notimplementederror

全部标签

android - Kotlin with Room and Dagger - 编译错误

我正在处理我的第一个AndroidKotlin应用程序。我的第一个Activity是处理模拟数据后,我现在正尝试从数据库中获取数据,但代码无法编译。Kotlin代码:@DaointerfaceTagGroupDao{@Query("select*fromTagGroup")fungetAll():LiveData>}这已生成此java代码:publicclassTagGroupDao_ImplimplementsTagGroupDao{privatefinalRoomDatabase__db;publicTagGroupDao_Impl(RoomDatabase__db){this._

android - 将类类型作为参数传递并针对 Kotlin 中的另一个对象检查类型

我正在尝试编写一种方法来等待一种类型的Activity出现以进行我的Espresso测试。我见过尝试等待对象出现在单独的Activity而不是测试开始的地方的例子,但到目前为止没有一个对我有用,而且我不想用空闲资源修改我的生产代码。在我的方法中,我想获取当前Activity,然后检查该Activity是否是我想要的特定类型的类。我基本上是在修改我发现的一些代码here使用Kotlin和通用类类型。不幸的是,我不知道如何格式化传入的参数(当前为Class)或者我在我的if中不正确地使用它陈述。下面写的不编译。关于如何将我想要的Activity类型作为参数传递给waitForActivit

android - kotlin 中的合成导入不起作用

在Fragment中,Anko提供的Kotlins布局合成导入不起作用。我正在尝试设置View的可见性,但它说View为空。我有以下代码。classHistoryFragment:Fragment(),HistoryContract.view,LoaderManager.LoaderCallbacks>{privatelateinitvarmPresenter:HistoryContract.Presenterprivatelateinitvaradapter:HistoryAdapteprivatevalloaderId:Int=101overridefunonLoadFinishe

android - 在 Kotlin Coroutines 生产者内部处理取消

是否可以在生产者构建器内部处理生产者取消?取消订阅回调可能很有用:privatefunchanges(key:String)=produce(UI,CONFLATED){vallistener=OnSharedPreferenceChangeListener{_,changedKey->if(key==changedKey)offer(Unit)}prefs.registerOnSharedPreferenceChangeListener(listener)???.onCancel{prefs.unregisterOnSharedPreferenceChangeListener(lis

android - 评论中的 Kotlin 分界线不起作用

在Java我经常用(或另一个html标签)像这样推荐,使评论易于阅读/***Line1*Line2*/在Kotlin中,我写了这样的评论,但它不起作用(“第2行”不要换行)。有什么方法可以实现它(任何设置或插件)? 最佳答案 Kotlin文档不支持HTML标签,但支持Markdown语法。据此WhenyoudowanttoinsertbreaktagusingMarkdown,youendalinewithtwoormorespaces,thentypereturn.查看更多信息https://daringfireball.net/

android - kotlin RecyclerView 分页

我需要让我的RecyclerView仅加载10个项目,并在滚动后加载更多10个项目并像这样工作。我使用Volley添加数组中的项目。这是我的RecyclerView适配器。classnewsAdapterconstructor(privatevalactivety:MainActivity,privatevalListOfCash:ArrayList,vallistener:BTNListener):RecyclerView.Adapter(),BTNListener{overridefungetItemCount():Int=ListOfCash.sizeoverridefunonC

android - 如何在 Kotlin 的 forEach 之外返回?

这个问题在这里已经有了答案:HowdoIdoa"break"or"continue"wheninafunctionalloopwithinKotlin?(2个答案)关闭4年前。我希望返回forEach外的aa@logError("Done")行,但是return@aa不行,而break@label也不起作用。而且,如果您使用return,它将在有趣的lookForAlice之外返回!dataclassPerson(valname:String,valage:Int)valpeople=listOf(Person("Paul",30),Person("Alice",29),Person(

android - Android Studio 中缺少 Kotlin 临时文件输出

我正在使用AndroidStudio3.2并尝试运行临时文件,但找不到println的输出位置。我的临时文件的内容:funmain(args:Array){println("Hello,world!")}但是输出窗口缺少“Hello,world!”我是不是找错地方了? 最佳答案 .kts文件不需要main函数。您可以在顶层添加打印语句。这可以解释有关args未使用的警告,因为main从未被调用。AscriptisaKotlinsourcefile(.kts)withtoplevelexecutablecode.Usingthecom

android - 使用 gradle 包装器在 Kotlin 枚举类构建中的方法声明无效

我有以下Kotlin枚举类:enumclassDurationModifier{GreaterThan{overridevaldisplayName="≥"},LessThan{overridevaldisplayName="≤"};abstractvaldisplayName:String}很长一段时间以来,它一直是我项目的一部分,并且编译得很好。这使用IntelliJ或AndroidStudio编译得很好,但是当我从命令行手动运行gradle构建时(./gradlewassembleDebug)我得到这个:e:{projectDir}/build/tmp/kapt3/stubs/{

android - Kotlin:在 fragment 内打开新 Activity

如何在使用按钮时在fragment内打开新的Activity?我试过了overridefunonViewCreated(view:View,savedInstanceState:Bundle?){super.onViewCreated(view,savedInstanceState)LogOut_btn.setOnClickListener{//FirebaseAuth.getInstance().signOut()valintent=Intent(this,Main::class.java)startActivity(intent)}}valintent=Intentdoesn'ts