Created
July 22, 2016 19:03
-
-
Save AaronC81/b437933bae2051cd859333d05f426468 to your computer and use it in GitHub Desktop.
Anko Fragments
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
inline fun ViewManager.frag(noinline fragment: () -> Fragment, theme: Int = 0, init: View.() -> Unit, fragInit: Fragment.() -> Unit): RelativeLayout { | |
var parentToFragment: RelativeLayout? = null | |
val childFragment = fragment() | |
childFragment.fragInit() | |
return ankoView({ | |
parentToFragment = RelativeLayout(it) | |
parentToFragment!!.id = 123123 // TODO: Replace with real ID | |
(it as Activity).fragmentManager.beginTransaction().add(parentToFragment!!.id, childFragment).commit() | |
parentToFragment!! | |
}, theme, init) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment