Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 5 years ago. Improve this question How can I build a color picker as given in the image using android? when an indicator is placed on
Tag: kotlin
Kotlin generics Array results in “Cannot use T as a reified type parameter. Use a class instead” but List does not
I have an interface that contains an array (or list) of T and some metadata. If I write the simplest implementation of the interface, I get a compile error on the emptyArray(): “Cannot use T as a reified type parameter. Use a class instead.” However, if I change both the interface and the implementation to a list, I have no
How to interpret and translate a Lottie animation from Kotlin to Java?
I have been trying to translate this Kotlin code to Java since the project is in Java. I am translating by looking into Kotlin syntax. However, there are still others that I am having a hard time understanding. https://github.com/airbnb/lottie-android/blob/master/LottieSample/src/main/kotlin/com/airbnb/lottie/samples/AppIntroActivity.kt Specifically: For the setViewPagerScroller, I was able to translate the first part. Answer The method setViewPagerScroller uses kotlin anonymous inner class
Android FATAL EXCEPTION at android.arch.lifecycle on Kotlin lang
i just try to convert my old android project in java to Kotlin and also add google Android Architecture Components to my project : and then when i run app faced with this errors : and this : how to fix that? thanks Answer By Updating LifeCycle Libs to Alpha 9 Problem Solved.
RxJava Live Reactive Queue (with on off switch)
Working on an android app in kotlin. I need to set up a system to be able to do work from a live queue (and observe the results of the work in a stream). But I also have to be able to toggle the “queue processing” depending on a couple external factors (which also come in as streams) like networkIsAvailable
Using functional interfaces with function types in Kotlin
When calling Java code from Kotlin, there is SAM conversion so that Java code like this: Can look like this: Now, I’m working on a Kotlin project and I want to define a functional interface as an event listener: In SomeClass I have a function to set the listener: And when I create an instance of this class and try
Convert indefinitely running Runnable from java to kotlin
I have some code like this in java that monitors a certain file: This is my kotlin code: I dont understand what Runnable I should pass into mHandler.postDelayed. What is the right solution? Another interesting thing is that the kotlin to java convertor freezes when I feed this code. Answer Lambda-expressions do not have this, but object expressions (anonymous classes)
What is the `it` in Kotlin lambda body?
For example in these two following codes: and In this code what does it mean? Answer it variable is an implicit parameter in lambda. One other helpful convention is that if a function literal has only one parameter, its declaration may be omitted (along with the ->), and its name will be it:
Difference between a class and object in Kotlin
I’m new to Kotlin and have recently converted a simple file from java to Kotlin. I am wondering why the Android converter changed my java class to a Kotlin object. Java: Converted Kotlin: Why wasn’t it: Any help would be greatly appreciated thanks. Answer A Kotlin object is like a class that can’t be instantiated so it must be called
How can I run Kotlin-Script (.kts) files from within Kotlin/Java?
I noticed that IntelliJ can parse .kts files as Kotlin and the code editor picks them up as free-floating Kotlin files. You are also able to run the script in IntelliJ as you would a Kotlin file with a main method. The script executes from top to bottom. This form is PERFECT for the project I’m working on, if only