```import kotlinx.android.synthetic.main.some_layo...
# android
d
Copy code
import kotlinx.android.synthetic.main.some_layout.view.*

//class defined here, custom view, which extends FrameLayout

init {
    val inflater = context.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
    inflater.inflate(R.layout.some_layout, this, true)
}
Note the debugger seems to be confused about what's actually imported, but the code works.
d
it doesn't work when class is not a View child. For example
Presenter
d
I don’t know the exact conditions needed to make the synthetic views work, but regardless, you shouldn’t be manipulating Views from a Presenter. The Presenter should pass data to your UI layer (custom view, fragment, activity, etc.) which should be responsible for updating the layout.
d
ok. just imagine i created my own Fragment, and it is not a child of framework's Fragment/Activity/View. is it possible to import synthetic view fields into such class?
d
I don’t think it will work if it doesn’t have a way to resolve a call to
findViewById()
, which might be difficult without it being a subclass of Fragment/Activity/View, I could be wrong though.