Can anyone help me
# android
n
Can anyone help me
stackoverflow 6
n
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
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
Why are you mentioning me? 😂 😕
a
? lol
you cannot use back as an int
n
how to solve? I need change my background image automatic according firebase value
e
what is the definition of your
Back
class?
n
do you see a github link? (pls)
a
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
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
right so its a boolean
n
Do you understand?
a
so can an instance of
back
be compared with
> 0
?
n
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
that I cannot tell you if this is valid in java
back > 0
n
pls
a
if you type it out in a java file, will
Copy code
Back back = ...instance
back > 0
compile?
n
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
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
ok
How to solve?(pls)
@Vishal
android:background="@{back.mDrawableResource > 0 ? @drawable/check2: @drawable/check2}"/>
r
Hey dude , why not just go through the android documentation?