https://kotlinlang.org logo
Docs
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
android
  • s

    Slackbot

    08/20/2020, 7:04 AM
    This message was deleted.
    :stackoverflow: 1
    g
    j
    • 3
    • 2
  • n

    Nikola Milovic

    08/20/2020, 1:53 PM
    Any library to go alongside Espresso for UI testing? I am lost on how to test anything inside a recycle-view properly.
    p
    • 2
    • 2
  • l

    Lilly

    08/20/2020, 4:14 PM
    Hi, I want to design a dark theme and checked the material design guidelines about that. Usually you take #121212 as baseline color for the surface and put an overlay of color white with an opacity of 8 (or 9% depending on elevation level) % on it. Can someone please explain me how I can figure out the true color (combination of both)
    In this case, it is #272727 which is a mix of #121212 and #FFFFFF (9%).
    I also read this tutorial which helps a lot but he didn't explain how to calculate the colors. https://blog.prototypr.io/how-to-design-a-dark-theme-for-your-android-app-3daeb264637
    • 1
    • 1
  • e

    ebtokyo

    08/20/2020, 4:33 PM
    Hi, after updating to Kotlin 1.4, our Android Studio 4.0.1 became super slow at code completion and at noting compilation failures as-you-type. Does anyone had similar issue? It impact productivity so much we will revert the Kotlin update.
    z
    • 2
    • 2
  • s

    Susheel

    08/20/2020, 8:56 PM
    After upgrading compile sdk and targetSdk to 29, Parcel.readXXXX and Bundle returns a nullable value. Does anyone know why this change was made?
    j
    i
    • 3
    • 10
  • b

    Ben Butterworth

    08/21/2020, 2:55 PM
    What jvm does everyone target their kotlin android apps to
    z
    • 2
    • 10
  • k

    KimJason

    08/22/2020, 2:57 PM
    @Madalin Valceleanu hello! May I ask you a question about the android-modular-architecture project?
    m
    m
    • 3
    • 14
  • b

    Ben Butterworth

    08/23/2020, 12:08 PM
    Does anyone use an alternative to Android file transfer they would recommend? (preferably available for macOS)
    :google: 3
    :stackoverflow: 4
    l
    j
    • 3
    • 6
  • s

    samuel

    08/23/2020, 6:04 PM
    I came across this in the viewbinding documentation.
    Note: Fragments outlive their views. Make sure you clean up any references to the binding class instance in the fragment’s 
    onDestroyView()
     method.
    Does this mean that using
    lazy
    as below could potentially leak?
    private val binding: SomeXmlViewBinding by lazy {
        SomeXmlViewBinding.inflate(layoutInflater)
    }
    
    private val button: View by lazy { binding.button }
    :yes: 2
    i
    • 2
    • 2
  • j

    Julius Marozas

    08/23/2020, 9:28 PM
    Is there a way to know when an application has been closed (swiped away in android recents screen)? I have a foreground service which should survive process death but would stop when the application has deliberately been closed by a user.
    i
    s
    • 3
    • 4
  • k

    Kevin

    08/24/2020, 7:05 AM
    Hi all, this is probably a newbie question. but i'm curious to know, whether in kotlin you can call components from other file into main file. i've tried to research about this before, but i can't find any resources that explaining about this stuff. here is the example of what i mean: main.xml
    <LinearLayout
       android:id="@+id/linear_main"
       xmlns:android="<http://schemas.android.com/apk/res/android>"
       xmlns:tools="<http://schemas.android.com/tools>"
       xmlns:app="<http://schemas.android.com/apk/res-auto>"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:orientation="horizontal"
       >
    
       <TextView
    			android:layout_width="match_parent"
    			android:layout_height="wrap_content"
    			android:text="Hello World"
    			android:textColor="@color/Black01"
    			/>
    
      /*insert some kind of tag in here to call the id of new_image element from second_file.xml*/
    
    
    
    </LinearLayout>
    second_file.xml
    <LinearLayout
       android:id="@+id/linear_second"
       xmlns:android="<http://schemas.android.com/apk/res/android>"
       xmlns:tools="<http://schemas.android.com/tools>"
       xmlns:app="<http://schemas.android.com/apk/res-auto>"
       android:layout_width="match_parent"
       android:layout_height="match_parent"
       android:orientation="horizontal"
       >
    
       <ImageView
                android:id="@+id/new_image"
    			android:layout_width="wrap_content"
    			android:layout_height="wrap_content"
                app:srcCompat="@drawable/button_image"
    			/>
    
    </LinearLayout>
    do note that the attached code in here is just an simple example code. as i would like to know, if it's possible or not to call only id of textview/imageview from the other xml file, into the main file.
    j
    • 2
    • 4
  • g

    Giulio

    08/24/2020, 11:19 PM
    Anyone knows what Android Studio/IntelliJ theme is being used in the jetpack tutorial? https://developer.android.com/jetpack/compose/tutorial
    p
    d
    +4
    • 7
    • 11
  • r

    Remon Shehata

    08/25/2020, 4:37 PM
    Can anyone help me? I need guidance on how to solve this problem. just guide me to use a design pattern to get rid of the repeated code. https://codereview.stackexchange.com/questions/248415/refactor-method-using-generic-method-or-design-pattern
    t
    • 2
    • 3
  • s

    Slackbot

    08/25/2020, 6:12 PM
    This message was deleted.
    j
    y
    • 3
    • 2
  • z

    ZariApps

    08/25/2020, 7:45 PM
    is there any good documention or videos on how to include APIs calls into your code?
    c
    • 2
    • 3
  • t

    Tony Mykhaylovsky

    08/25/2020, 10:52 PM
    Thoughts on Jetbrains Compose? I'm working with SwiftUI at the moment and would really prefer to develop UI in the same manner. Is this a good Slack group to stay up to date on Kotlin+Compose developments?
    z
    • 2
    • 2
  • e

    Eugene

    08/26/2020, 8:42 AM
    Good day to all! 🙂 My name is Eugene and I'm a product manager at JetBrains. Currently, I look for Java developers who continue to use Java in their production projects. I'd like to learn more about your UCs and why's do you use Java instead of Kotlin. I think most of you have completely switched to Kotlin, but perhaps you know people out of this channel who continue to use Java 🤔 Just DM me and I'll ask a few questions :android: That's it. Have a nice day and happy coding 👩‍💻
    👍 1
    l
    g
    +2
    • 5
    • 15
  • g

    genovich

    08/26/2020, 11:24 AM
    I’m not sure if it’s ok to share android-related articles here, but I wrote one and maybe you can find it interesting
    a
    • 2
    • 3
  • j

    John O'Reilly

    08/26/2020, 5:49 PM
    I just updated to AS 4.2.0-alpha8 and now getting
    ClassNotFoundException: kotlin.KotlinNothingValueException
    - anyone else come across this?
    ➕ 1
    l
    c
    p
    • 4
    • 9
  • m

    mohamadreza jafarzade

    08/26/2020, 9:58 PM
    I have two fragments. Fragment A implements a listener. when I want to open fragment B, I set this listener directly in it and hold it as a lateinit var. Here is my problem. when i rotate screen in fragment B, I get error that I havent initialize the lateinit variable. How can i solve this?
    i
    • 2
    • 2
  • h

    henrikhorbovyi

    08/27/2020, 2:49 AM
    Hello people, How can I use Kotlinx.synthetic and Kotlin 1.4 I got this error
    java.lang.AssertionError: Unbound symbols not allowed
    	Unbound public symbol for public kotlinx.android.synthetic.main.fragment_onboard/view
    r
    i
    • 3
    • 5
  • g

    gowthamgts

    08/27/2020, 8:42 AM
    came across this (https://www.reddit.com/r/mAndroidDev/comments/igws6l/of_course_the_first_thing_i_want_to_open_is_the/) and this pretty much happens to me all the time. any way to hide auto generated files from showing up on search/navigation?
    s
    • 2
    • 2
  • j

    Jakekudur

    08/27/2020, 9:03 AM
    message has been deleted
    j
    • 2
    • 32
  • t

    Tijs Gobbens

    08/27/2020, 9:04 AM
    I'm wondering if there is a better (e.g. less code) way to do this, in my ViewModel i want to have a LiveData object that can only be changed from the viewModel it self (e.g. the view should not change it, only observe), I use the next code for this, is there a better way of doing this?
    private val _someData = MutableLiveData<String>()
        val someData: LiveData<String> = _someData
    g
    j
    +2
    • 5
    • 13
  • k

    Kevin

    08/27/2020, 10:30 AM
    hi all, i was wondering if there is a way to set part of text in TextView to bold/italic, without have to use .kt file to do it? all the resources that i found, need the use of .kt file to do it. in example it should be like this: a TextView with text value of "Hello World", i would like to make the word "Hello" to be bold or italic, but i want to do it simply in the xml file, not in the kt file.
    b
    m
    • 3
    • 3
  • e

    Erik

    08/27/2020, 10:55 AM
    AndroidX KTX provides extensions, for example
    LifecycleOwner.lifecycleScope()
    . However, there are multiple dependencies related to this example:
    androidx.lifecycle:lifecycle-livedata-core-ktx
    androidx.lifecycle:lifecycle-livedata-ktx
    androidx.lifecycle:lifecycle-reactivestreams-ktx
    androidx.lifecycle:lifecycle-runtime-ktx
    androidx.lifecycle:lifecycle-viewmodel-ktx
    (this particular example is listed here: https://developer.android.com/kotlin/ktx/extensions-list#for_lifecycleowner_2) 👉❓ How can I find out which specific dependency provides this particular feature? ❓👈
    s
    i
    • 3
    • 2
  • w

    Will Nixon

    08/27/2020, 4:06 PM
    Hi all - I’m trying to use SharedPreferences in my app in order to save a few preferences that then need to update pretty instantaneously inside the app. I have a settings page, where the user can switch from light to dark mode, and also update the voice of a TTS functionality. When the user ‘saves changes’ - I call editor.putXXXX(key, value).apply() for each setting and then close out of the settings page. Unfortuntately, I neither see the settings changed in my main activity, nor see the updated settings when I go back into the settings page. I understand that .apply() is asynchronous - I suspect that calling .apply() for each setting is going to cancel previous calls to .apply() - am I able to make several “puts” and then call .apply() just the once to make those several changes in one go? Why would I not see immediate changes in my main activity even if I call ‘sharedPrefs.getXXX’ again? I’m assuming it’s just an issue whereby the apply() function hasn’t actually finished yet? I’ve tried Googling and SOing for solutions but not getting anywhere (edited)
    r
    i
    • 3
    • 7
  • o

    Oleg Siboglov

    08/27/2020, 4:48 PM
    Hey all. I’m using the
    LiveData.observe(...)
    function from the
    lifecycle-livedata-core-ktx
    library. Today I noticed that I’m getting a warning from Android Studio in regards to this function call. Anyone know what this is about?
    Candidate resolution will be changed soon, please use fully qualified name to invoke the following closer candidate explicitly:
    public open fun observe(owner: LifecycleOwner, observer: Observer<in ScreenData!>): Unit defined in androidx.lifecycle.LiveData
    i
    • 2
    • 2
  • a

    Afzal Najam

    08/27/2020, 6:09 PM
    Is this a bug in LiveData? Steps: 1. Call
    liveData.postValue(StateOne)
    2. Call
    liveData.postValue(StateTwo)
    Actual: The LiveData observer only receives
    StateTwo
    because inside
    postValue
    , while the
    mPostValueRunnable
    is being posted from the first call,
    pendingData
    gets replaced by the second call. Is that expected or should LiveData be posting two separate runnables, one by one?
    i
    c
    • 3
    • 10
  • j

    Junaid Sakib

    08/27/2020, 6:14 PM
    Is the
    LayoutContainer
    for
    ViewHolder
    pattern still in experimental state, actually I am not finding much documentation around it, or maybe I am not looking in the right place?
    f
    • 2
    • 3
Powered by Linen
Title
j

Junaid Sakib

08/27/2020, 6:14 PM
Is the
LayoutContainer
for
ViewHolder
pattern still in experimental state, actually I am not finding much documentation around it, or maybe I am not looking in the right place?
f

flosch

08/28/2020, 9:34 AM
This will also stay in experimental state, since it is recommended to use
ViewBinding
instead of
kotlin-synthetics
With
ViewBinding
you do not need to extend the
ViewHolder
with anything: Adapter
override fun onCreateViewHolder(
    parent: ViewGroup,
    viewType: Int
): SomeViewHolder = SomeViewHolder(
    ItemSomeBinding.inflate(LayoutInflater.from(parent.context), parent, false)
)
ViewHolder
internal class SomeViewHolder(
    private val binding: ItemSomeBinding
) : RecyclerView.ViewHolder(binding.root) {

    fun bind(item: SomeItem) {
        binding.textView.text = "${item.id}"
    }
}
j

Junaid Sakib

08/29/2020, 1:44 PM
Thanks Florian, actually my use case was based on: https://github.com/Liverm0r/DelegateAdapters, however I feel - I might as well convert this into a view binding holder.
View count: 6