Created
September 29, 2017 12:59
-
-
Save whalemare/e5cb7a1af76e15e45a0e36964e9a3f6a to your computer and use it in GitHub Desktop.
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
package com.mscharhag.groovytodo.activities | |
import android.app.Activity | |
import com.mscharhag.groovytodo.R | |
import com.mscharhag.groovytodo.ToDo | |
class MainActivity extends Activity { | |
@Override | |
protected void onStart() { | |
super.onStart() | |
setContentView(R.layout.create_todo) | |
def button = findViewById(R.id.newTodoButton) | |
// use groovy multiple assignment to map view ids to variables | |
def (title, description) = [R.id.newTitle, R.id.newDescription].collect(this.&findViewById) | |
button.onClickListener = { | |
application.toDos << new ToDo(title.text.toString(), description.text.toString()) | |
finish() | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment