Kotlin provides the ability to extend a class with new functionality without having to inherit from the class or use any type of design pattern such as Decorator. This is done via special declarations called extensions.
Questions tagged [kotlin-extension]
333 questions
0
votes
1 answer
Member variables cannot be correctly converted to lambda expressions
As above
data class Person(val name: String, val age: Int) : Comparable {
override fun compareTo(other: Person): Int {
return compareValuesBy(this, other, Person::name, Person::age)
}
}
The above code is running correctly,…

zm chen
- 3
- 1
0
votes
1 answer
Extension functions issue
Run into some difficulties while using extension functions with existing java api. Here some pseudocode
public class Test {
public Test call() {
return this;
}
public Test call(Object param) {
return this;
}
public void configure1()…

c0ld
- 770
- 4
- 15
0
votes
2 answers
Replace lamda in an extension function
This is an extension function:
fun Collection.fold(initial: R, combine: (acc: R, nextElement: T) -> R): R {
var accumulator: R = initial
for (element: T in this) {
accumulator = combine(accumulator, element)
}
…

Johann
- 27,536
- 39
- 165
- 279
0
votes
1 answer
captured and displayed image on imageView, now i want to pass the imageView to another activity
This is my code on android studio using kotlin to capture and show image on main activity, I want that captured image to be displayed on my other activity. After image has been captured, the image will be displayed on the imageView on main Activity,…
user10635891
0
votes
1 answer
Kotlin android extensions in custom view with databinding
I have a Custom Linear layout and an xml file in with 3 checkboxes. The Custom linear layout looks roughly like this:
class AdvancedBox : LinearLayout, DefineExchangesDialog.DefineExchangesDialogListener {
private lateinit var mBinding:…

Doflaminhgo
- 577
- 5
- 16
0
votes
1 answer
Custom fragment transition with kotlin
Do you know how to inject custom transition animation to the underneath replaceFragment() method using kotlin? It is a fragment to fragment transition
private inline fun FragmentManager.inTransaction(func: FragmentTransaction.() ->…

DCoder
- 11
- 5
0
votes
0 answers
How to call methods which type are return Module using Kotlin?
I have a two files one.kt and two.kt, i have innerclass in one.kt file. i want to call the that inner class when some action performed like button click in Two.kt file. I tried some of ways the innerclass is called but method does not call. please…

Karthikeyan
- 385
- 3
- 7
- 18
0
votes
0 answers
How to build a XMLRPC client in Kotlin managing dependency with Gradle?
Hi I'm working with Spring and Kotlin building an XMLRPC client but I don't find any resource about it... And I'm trying to install the apache Library to consume my xmlrpc client.
This is my gradle file:
buildscript {
ext {
kotlinVersion…

norbertoonline
- 351
- 1
- 12
0
votes
1 answer
How to print the value of getter method
I created the below example in eclipse. I am following a tutorial, and it mentioned that I can use print(s1.captain) to print the captain name for example. The tutorial wants to show that kotlin automatically generate the setters and getters.
In my…

Amrmsmb
- 1
- 27
- 104
- 226
0
votes
0 answers
Kotlin extension view binding : "Overload resolution ambiguity.." error on editor on custom button
I am using the new kotlin extension for view binding but I am having this annoying warning red underline message custom_button.setOnClickListener{} stating "Overload resolution ambiguity.."
I am trying to use my custom button class which extends…

bruce
- 31
- 1
- 5
0
votes
0 answers
Error build kotlin project in android studio
I am trying to learn Kotlin. i updated Android studio to the latest version an di created a sample project. but when i tried to edit the layout file,and build
the project, I received the below posted error messages.
please let me know how to fix…

Amrmsmb
- 1
- 27
- 104
- 226
0
votes
2 answers
Media player with circular ProgressBar
I wanna connect my media player to the progress bar Here is my code :
var media55 :MediaPlayer
var progressBar55 :ProgressBar
progressBar55=findViewById(R.id.progressBar)
media55 = MediaPlayer()
media55.setDataSource("SONG…

MKS
- 15
- 5
0
votes
1 answer
How do I package extension functions in a library jar?
I have a set of extension functions that I would like to package into a jar and include in a project, but I can't seem to assess the extension functions from the jar. I can access non-extension functions from the same jar.
For example if I create a…

nPn
- 16,254
- 9
- 35
- 58
0
votes
1 answer
How to access extension property inside object from outside class?
Example:
class Foo {
fun foo() = Unit
}
object Bar {
val Foo.foo get() = Unit
}
fun Foo.bar() = Bar.foo
Extension symbols aren't static when inside a class instance, so I don't see why this wouldn't be possible by simply passing in the…

SUPERCILEX
- 3,929
- 4
- 32
- 61
0
votes
1 answer
How to put header in url using volley in Kotlin?
My code-
val accessTokenRequest: JsonObjectRequest = JsonObjectRequest(Request.Method.GET, url,
Response.Listener { response ->
},
Response.ErrorListener { error ->
…

shivam Kapoor
- 105
- 2
- 3
- 9