kotlin-extension Questions
16
Solved
Is there any fancy way to implement debounce logic with Kotlin Android?
I'm not using Rx in project.
There is a way in Java, but it is too big as for me here.
Ezzo asked 14/6, 2018 at 13:27
7
Solved
I am trying to write a kotlin extension function for Context which will start a new activity in android with given class name and list of intent extras. I am able to successfully start activity wit...
Koster asked 16/12, 2018 at 15:32
9
Solved
I'm getting error in Kotlin in this part:
class GitHubRepoAdapter(
private val context: Context,
private val values: List<GithubRepo>
) : ArrayAdapter<GithubRepo>(
context,
R.layou...
Lefkowitz asked 17/5, 2017 at 21:45
9
Solved
In Kotlin class, I have method parameter as object (See Kotlin doc here ) for class type T. As object I am passing different classes when I am calling method.
In Java we can able to compare class u...
Hypercritical asked 21/5, 2017 at 15:47
2
Solved
I have created a data class
data class Something (
val a : String,
val b : Object,
val c : String
)
as later in my program, I need the string representation of this data class I tried to extend...
Shimberg asked 13/3, 2016 at 13:41
4
Solved
I want to use the features of kotlin @Parcelize,
I have apply the plugin: 'kotlin-android-extensions' on gradle, and I added
androidExtensions {
experimental = true
}
but errors continue to...
Undis asked 20/10, 2018 at 5:29
3
Solved
If we want to test an extension function on a type, we can create an instance of this type, call the function and check the returned value. But what about testing extension functions defined inside...
Congreve asked 5/6, 2018 at 14:21
4
Solved
Is it possible to add a new static method to the java.lang.Math class in Kotlin? Usually, such things are possible in Kotlin thanks to Kotlin Extensions.
I already tried doing the following in a f...
Anne asked 25/11, 2015 at 8:18
1
Solved
Is it possible to call an extension function from another package without importing it?
Given an extension function:
package ext
fun Int.plusOne() = this + 1
Is there any way to call this function...
Pathway asked 17/2, 2023 at 10:48
5
Solved
How to iterate over HashMap in Kotlin?
typealias HashMap<K, V> = HashMap<K, V> (source)
Vidar asked 9/11, 2017 at 14:18
8
Solved
Hello I'm making an app using Android Studio and the Kotlin language and am having trouble getting my button to open a new activity. I have the button created in my xml file but I can't find the KO...
Dispersant asked 14/7, 2017 at 17:2
2
Solved
I have some extension functions function below.
fun EditText.setEmailValidationListener(): TextWatcher {
val textWatcher = object : TextWatcher {
override fun beforeTextChanged(text: CharSequenc...
Gwin asked 19/8, 2016 at 2:32
4
Hey after updating Android Studio to 3.1 Stable version i am getting following error to all my projects. Any help will be appreciated.
Could not download kotlin-reflect.jar (org.jetbrains.kotlin...
Byrnes asked 27/3, 2018 at 7:51
0
I have an extension function for an enum that return a string resource.
In order to make sure that the function only returns a valid String resource, I have annotated the function with @StringRes.
...
Bestialize asked 1/2, 2022 at 19:34
5
I'm following this article to collect flows in UI. But I couldn't resolve repeatOnLifeCycle API in my code. I have added the below dependency, though.
lifecycle:lifecycle-runtime-ktx:2.4.0-alpha03
...
Masquer asked 4/8, 2021 at 18:19
3
Solved
I am new to kotlin and I am trying to make a copy of a list of objects.The problem I am having is that when I change items in the new copy, the old list gets changed as well. This is the object:
c...
Maximilianus asked 23/7, 2018 at 13:32
4
Solved
I just noticed this lint error:
Call requires API Level 24 (current min is 19) java.util.map#foreach
when I use the extension function forEach on a MutableMap in Kotlin.
This didn't happen whe...
Dozen asked 25/6, 2017 at 23:21
4
Solved
I am trying to find a tail function in List<T> but I couldn't find any. I ended up doing this.
fun <T> List<T>.tail() = this.takeLast(this.size -1)
Is there a better way to do ...
Heart asked 4/3, 2016 at 23:35
4
Solved
I am aware that extension functions are used in Kotlin to extend the functionality of a class (for example, one from a library or API).
However, is there any advantage, in terms of code readability...
Jordison asked 8/11, 2017 at 13:55
3
Solved
also compiles and runs from Android Studio:
val greeted = "World".also { println("Hello $it") }
Yet the editor highlights also and it as errors and don't give any help with intellisense. apply s...
Clarino asked 17/7, 2017 at 14:2
3
Solved
I have multi module kotlin gradle project in github here.
One of my sub project introducing-coroutines with build file build.gradle.kts file is here
The contents of build.gradle.kts is -
import...
Carsoncarstensz asked 21/1, 2019 at 3:24
5
Solved
I'm using Android Studio 3.0 RC2 & Kotlin.
When I try to access a UI component the app crashes unless I first write findViewById. I thought Kotlin was supposed to get rid of having to write fi...
Karafuto asked 23/10, 2017 at 5:21
3
Solved
I was trying to create an extension function to create object of view holder for recycler view adapter
inline fun <reified T: RecyclerView.ViewHolder> ViewGroup.createViewHolder(@LayoutRes r...
Mongol asked 24/5, 2018 at 13:42
2
Solved
I am working in Kotlin using a Kotlin-native library object containing a method whose .nameIsMuchTooLongAndIsStillNotClear. In a manner similar to typealias, I want to create an alias to the method...
Lewin asked 8/10, 2017 at 12:51
5
Solved
I'd like to access Java's private field when using Kotlin extension function.
Suppose I have a Java class ABC. ABC has only one private field mPrivateField. I'd like to write an extension functio...
Yiddish asked 16/7, 2017 at 17:49
1 Next >
© 2022 - 2024 — McMap. All rights reserved.