https://kotlinlang.org logo
Title
n

neuber

01/13/2019, 2:21 AM
Can anyone help me
:stackoverflow: 6
n

neuber

01/13/2019, 3:57 AM
I see it. I have issue now. I need change a androidbackground img using databindind variable to determine which selector file I will use
@Vishal @agrosner @arekolek @Eduard Boloș
👎 1
😂 1
Help me pls
e

Eduard Boloș

01/14/2019, 2:44 PM
out of curiosity, did you randomly pick some people to tag? also, you are doing
back > 0 ? ...
, but
back
is not a number type from what it looks from your declaration, so that is the error.
a

arekolek

01/14/2019, 2:44 PM
Why are you mentioning me? 😂 😕
a

agrosner

01/14/2019, 2:45 PM
? lol
you cannot use back as an int
n

neuber

01/14/2019, 2:46 PM
how to solve? I need change my background image automatic according firebase value
e

Eduard Boloș

01/14/2019, 2:47 PM
what is the definition of your
Back
class?
n

neuber

01/14/2019, 2:47 PM
do you see a github link? (pls)
a

agrosner

01/14/2019, 2:47 PM
also just think about it for a second...if you tried that in java you could not do the same thing. so what are you checking for?
instead of us giving you the answer
n

neuber

01/14/2019, 2:50 PM
my ideal solution would be for <layout> (variable databinding) in check.xml, but unfortunately it is not supported.
then I will can set this, in viewmodel/databinding
android:state_checked="true" />
or
android:state_checked="false" />
a

agrosner

01/14/2019, 2:51 PM
right so its a boolean
n

neuber

01/14/2019, 2:51 PM
Do you understand?
a

agrosner

01/14/2019, 2:52 PM
so can an instance of
back
be compared with
> 0
?
n

neuber

01/14/2019, 2:52 PM
I need togglebutton (to swap the image when it clicks) and databinding (to automatically change the background image) the two simultaneously
@agrosner You said so can an instance of
back
be compared with
> 0
?
How to I do this?
a

agrosner

01/14/2019, 2:55 PM
that I cannot tell you if this is valid in java
back > 0
n

neuber

01/14/2019, 2:55 PM
pls
a

agrosner

01/14/2019, 2:56 PM
if you type it out in a java file, will
Back back = ...instance
back > 0
compile?
n

neuber

01/14/2019, 2:57 PM
I don't know
Why I can not do this in kotlin?
In my current github project?
sorry. this last sentence is a statement and not a question
a

agrosner

01/14/2019, 3:00 PM
you can in kotlin, its pretty similar. but its rhetorical question. No you cannot do that for semi-obvious reason.
Back
is not a number, its an object. so you cant compare it in databinding too because its not a number
n

neuber

01/14/2019, 3:00 PM
ok
How to solve?(pls)
@Vishal
android:background="@{back.mDrawableResource > 0 ? @drawable/check2: @drawable/check2}"/>
r

rkeazor

01/16/2019, 1:14 PM
Hey dude , why not just go through the android documentation?