Created
November 15, 2016 13:09
-
-
Save sembozdemir/631b08c5746221990a17afb81829e69e to your computer and use it in GitHub Desktop.
ToDoKotlin - MainActivity.kt (with Anko DSL)
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
class MainActivity : AppCompatActivity() { | |
val todoListAdapter = TodoListAdapter() | |
override fun onCreate(savedInstanceState: Bundle?) { | |
super.onCreate(savedInstanceState) | |
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