Skip to content

Instantly share code, notes, and snippets.

@sembozdemir
Created November 15, 2016 14:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sembozdemir/b348c8026e5a76df26d081f04bb04edd to your computer and use it in GitHub Desktop.
Save sembozdemir/b348c8026e5a76df26d081f04bb04edd to your computer and use it in GitHub Desktop.
ToDoKotlin - MainActivityUI.kt
class MainActivityUI(val todoListAdapter: TodoListAdapter) : AnkoComponent<MainActivity> {
override fun createView(ui: AnkoContext<MainActivity>) = with(ui) {
verticalLayout {
recyclerView {
val orientation = LinearLayoutManager.VERTICAL
layoutManager = LinearLayoutManager(ctx, orientation, false)
addItemDecoration(DividerItemDecoration(ctx, LinearLayout.VERTICAL))
adapter = todoListAdapter
}.lparams(width = matchParent,
height = dip(0),
weight = 1f)
val editText = editText {
hint = "Add note..."
}
button {
text = "Add"
onClick {
val note = editText.asString()
todoListAdapter.add(note)
editText.clear()
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment