Questions tagged [kotlin-android-extensions]

Questions related to Kotlin Android Extensions

Kotlin Android Extensions

721 questions
6
votes
3 answers

Kotlin crashes in PasswordTransformationMethod while Java works fine

The code below crashes in Kotlin/Android with the stack trace provided on the bottom. It was converted from Java/Android, which didn't have such a problem. Original Java code is provided as well. The crash happens when I try to add a character to a…
Oleg Gryb
  • 5,122
  • 1
  • 28
  • 40
6
votes
1 answer

Kotlin's @Parcelize throws NPE on writeToParcel()

I have this set of data classes, all in the same file: @Parcelize data class Response(val RecordView: RecordView):Parcelable @Parcelize data class RecordView(val Records: List):Parcelable @Parcelize data class Gid(val Value:…
6
votes
4 answers

Kotlin explain me about Backing Fields

I have been looking at Kotlin official tutorial. I came across the topic called Backing Fields It says, Classes in Kotlin cannot have fields. However, sometimes it is necessary to have a backing field when using custom accessors. For these…
Zumry Mohamed
  • 9,318
  • 5
  • 46
  • 51
6
votes
4 answers

Kotlin - Android can we implement OnClickListener on Class?

I'm starting out with Kotlin and seems that onClick does not trigger if I implement it on an Activity Class class MainActivity : AppCompatActivity(), View.OnClickListener{ override fun onCreate(savedInstanceState: Bundle?) { …
johnguild
  • 435
  • 1
  • 5
  • 25
6
votes
1 answer

using Kotlin @Parcelize together with polymorphism

Hey I'm using one model as DTO, JsonCreator and Percelize my problem is that i want to use polymorphism (disassemble common part) and have no idea how to write it in Kotlin. @Parcelize @Entity open class Location (var lat: Double = 0.0, var lng:…
murt
  • 3,790
  • 4
  • 37
  • 48
6
votes
1 answer

Android studio 3: Outdated Kotlin Runtime

I don't use kotlin in my current a project, but always showing following warning: When I click to "Update runtime" will be show following popup: And here dependencies who i used: Anybody know how to solve this google trick? **Edit This is bug of…
6
votes
1 answer

NoSuchMethodError using @Parcelize Annotation in Kotlin

I'm currently trying out the experimental (which might be why it's not working...) @Parcelize annotation to generate Parcelable code. Most types seem to be working fine, but I'm having issues with Serializables throwing a NoSuchMethodError: …
6
votes
1 answer

Android Studio / Kotlin - invalid error "Overriding method should call super"

I have a BaseActivity class which is extended by a ContainerActivity class. Because I want to use BaseActivity in several other projects I moved it to an Android library that I added as a gradle dependency to these other projects. Other than moving…
zafrani
  • 4,030
  • 5
  • 31
  • 39
6
votes
2 answers

Kotlin reified type function as function extension - Callable from Java?

I'm trying to use a function with reified type as extension function but I don't think that it's possible because after I checked the generated bytecode I have find that the method signature is private, any work around to make it public…
6
votes
1 answer

Unable to reduce a list of booleans in kotlin

I am trying to map to boolean and reduce in kotlin. This is my code class Model{ fun isEmpty() : Boolean } list.asSequence().map { model -> { model.isEmpty() } }.reduce { acc, next -> (acc && next)} But compiler gives me…
Ashwin
  • 12,691
  • 31
  • 118
  • 190
6
votes
3 answers

getActivity() / context in a ViewHolder in Kotlin Android

I'm building a ViewHolder and Adapter for a Fragment and when I try to make an OnClick for the ViewHolder, none of the contexts I pass in work. There is no activity from getActivity() that I can use, and p0!!.context nor itemView.context work…
6
votes
1 answer

I can't understand source code implementation of string.kt in kotlin

In kotlin source code, I can't understand how to implement of length of String.kt , it is as following: package kotlin public class String : Comparable, CharSequence { companion object…
6
votes
1 answer

Reference View From Included Layout

I have a fragment layout with the following include tag:
Hobbajt
  • 267
  • 3
  • 14
6
votes
2 answers

Kotlin,Java,multidex,Dagger 2,Butterknife and Realm: transformClassesWithJarMergingForDebug: duplicate entry: org/jetbrains/annotations/NotNull.class

We have existing Java Android code. We want to painlessly slowly start moving to Kotlin. We use Dagger 2, Butterknife and Realm. We use Java 8 compiler (but our targetCompatibility and sourceCompatibility are 1.7). I've been roaming the web for…
Tar
  • 8,529
  • 9
  • 56
  • 127
5
votes
2 answers

Why do I get "unresolved reference" error for my view's name/ID when I type it in Kotlin?

I am following a tutorial exactly. I gave the view a name in the layout XML file under android:id. When I type that name in Kotlin, it is highlighted in red and there is an "unresolved reference" error. For example, in XML…
Tenfour04
  • 83,111
  • 11
  • 94
  • 154