kotterknife icon indicating copy to clipboard operation
kotterknife copied to clipboard

Bind view in arbitrary class

Open sargunv opened this issue 8 years ago • 2 comments

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.

sargunv avatar Jun 30 '16 01:06 sargunv

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

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

mustafin avatar Mar 27 '17 06:03 mustafin

@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<*>?

eugenio-caicedo avatar Mar 05 '18 21:03 eugenio-caicedo