Skip to content

Instantly share code, notes, and snippets.

@lynas
Last active February 18, 2019 15:38
Show Gist options
  • Save lynas/dcba002ce5afabf6454c8765ab3f3430 to your computer and use it in GitHub Desktop.
Save lynas/dcba002ce5afabf6454c8765ab3f3430 to your computer and use it in GitHub Desktop.
android fragment using anko
class MyFragment: Fragment(){
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
return UI {
linearLayout{
editText()
button("OK")
}
}.view
}
}
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
val fragment = MyFragment()
linearLayout {
id = 1
fragmentManager.beginTransaction().replace(1,fragment).commit()
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment