Created
November 15, 2016 14:20
-
-
Save sembozdemir/b348c8026e5a76df26d081f04bb04edd to your computer and use it in GitHub Desktop.
ToDoKotlin - MainActivityUI.kt
This file contains hidden or 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
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