Skip to content
This repository has been archived by the owner on Sep 12, 2019. It is now read-only.

Bind view in arbitrary class #42

Open
sargunv opened this issue Jun 30, 2016 · 2 comments
Open

Bind view in arbitrary class #42

sargunv opened this issue Jun 30, 2016 · 2 comments

Comments

@sargunv
Copy link

sargunv commented Jun 30, 2016

It would be nice to be able to do something like this:

class Sample : KotterKnifeTarget {
    override val rootView = something
    val textView = bindView<TextView>(R.id.foo) /* finds the view from rootView */
}

The view binding extension methods would be on KotterKnifeTarget. This way we could use KotterKnife with Renderers or anywhere else.

@mustafin
Copy link

What is the advantage of having that if you can just do

class Sample {
    val textView = something.bindView<TextView>(R.id.foo)
}

@eugenio-caicedo
Copy link

@mustafin but I am not sure about this:

class Sample {
    val textView = something.bindView<TextView>(R.id.foo)
}

That view method returns an object of type ReadOnlyProperty and not an object of type TextView. I can use the getValue method but which is the value for the parameter property: KProperty<*>?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants