Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't implement this im my kotlin project to change drawable color #2

Open
ghost opened this issue Dec 6, 2017 · 0 comments
Open

Comments

@ghost
Copy link

ghost commented Dec 6, 2017

Hi @neuberfran,
I'm not sure that I understand you. Could you please rephrase.

This class using only with data binding. You need to create your own ViewModel class,
add val background = ObservableBackground(),
setup data binding in xml and set android:background="@{viewModel.background}"

I have a question:

what I put in mainactivity?

other

this is correct adapter:

class ValAdapter {

companion object {


    @BindingAdapter("android:background")
    @JvmStatic
    fun setIntToDrawable(@NonNull button: Button, @NonNull anInt: Int) {
        button.background = button.context.getDrawable(anInt)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

0 participants