1

i'm create Textview with non-english id in my layout.xml then i want to use it in activity.kt

layout.xml,

<TextView
    android:id="@+id/sonuç"
    .
    .
    ... />

activity.kt,

sonuç.text = "Hello World"

I'm getting an error, Unresolving reference:sonuç

What is the solution?

Update!

var sonuç : TextView = findViewById(R.id.sonuç)
sonuç.text = "Hello World"

This code worked fine in Kotlin. Why?

K.Os
  • 5,123
  • 8
  • 40
  • 95
  • This may helps you: https://stackoverflow.com/questions/34169562/unresolved-reference-kotlinx – pRaNaY Sep 17 '17 at 13:21
  • 1
    The code worked fine because that's the proper way of accessing and manipulating visual elements in android. You have to find the view before you can modify its properties. – Tharkius Sep 17 '17 at 14:36
  • 3
    @Tharkius Except `kotlin-android-extensions` plugin allows you to access views via extension properties by using their ID as property name. So the real question is @HalilONCEN Did you `apply plugin: 'kotlin-android-extensions'` in your module build.gradle file? If you did and it still doesn't work, you should make a feature request here https://youtrack.jetbrains.com/oauth?state=%2Fissues%2Fkotlin – Eugen Pechanec Sep 17 '17 at 14:42
  • @EugenPechanec Didn't know about that, thanks for mentioning. That's a very neat plugin indeed :D – Tharkius Sep 17 '17 at 14:47
  • @EugenPechanec yes, this is in my build.gradle file `apply plugin: 'kotlin-android-extensions'` – Halil ONCEN Sep 17 '17 at 15:16
  • @HalilONCEN In that case it looks like the plugin does not support IDs with non-ASCII characters. I suggest you use only ASCII for now. In the meantime leave a bug report on YouTrack. – Eugen Pechanec Sep 17 '17 at 15:22
  • @EugenPechanec thanks. I'm reported. [https://youtrack.jetbrains.com/issue/KT-20299](https://youtrack.jetbrains.com/issue/KT-20299) – Halil ONCEN Sep 17 '17 at 15:28
  • 1
    @HalilONCEN Awesome! You can post it as an answer (you can answer your own questions) and update it later when the feature is implemented. – Eugen Pechanec Sep 17 '17 at 16:41

0 Answers0