Skip to content
This repository has been archived by the owner on Jul 13, 2020. It is now read-only.

something issues of anko.include() dsl #759

Open
gfzy9876 opened this issue Sep 10, 2019 · 0 comments
Open

something issues of anko.include() dsl #759

gfzy9876 opened this issue Sep 10, 2019 · 0 comments

Comments

@gfzy9876
Copy link

gfzy9876 commented Sep 10, 2019

inline fun <T: View> Context.include(layoutId: Int, init: (@AnkoViewDslMarker T).() -> Unit): T { @Suppress("UNCHECKED_CAST") return ankoView({ ctx -> ctx.layoutInflater.inflate(layoutId, null) as T }, 0) { init() } } inline fun <T: View> Activity.include(layoutId: Int, init: (@AnkoViewDslMarker T).() -> Unit): T { @Suppress("UNCHECKED_CAST") return ankoView({ ctx -> ctx.layoutInflater.inflate(layoutId, null) as T }, 0) { init() } }
I use include to help me of inflating View in custom view, and recyclerView's item ,but some times is not simply, for example:
when i want to inflate an RecyclerView item, i will call Inflater.from.inflate(R.layout.xxxx,parents, false);
when i want to just create a View, i will call Inflater.from.inflate(R.layout.xxx, null, false);
when i want to create a custom View,i will call Inflter.from.inflate(R.layout.xxx, this, true);

but anko not support to put the enough parameters to select.

also:
i want to create a Linearlayout by anko in activity, but don't set it to ContentView ,I can't call Activity.include instead of Context.include, so i must force convert 'Activity' to 'Context', that makes me entangled

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

No branches or pull requests

1 participant