Upgrade to Pro — share decks privately, control downloads, hide ads and more …

layout xml? try Anko!

Moyuru Aizawa
December 09, 2016

layout xml? try Anko!

Shibuya.apk
Ankoについての発表

TwitterID変えました。@lvla0805 -> @MoyuruAizawa

Moyuru Aizawa

December 09, 2016
Tweet

More Decks by Moyuru Aizawa

Other Decks in Programming

Transcript

  1. JU`TIBSEMZEPOFCFDBVTFJU`TTPNFXIBUVHMZBOEIBSEUPNBJOUBJO 8IJMFZPVDBODSFBUF6*QSPHSBNNBUJDBMMZʜ val act = this val layout = LinearLayout(act)

    layout.orientation = LinearLayout.VERTICAL val name = EditText(act) val button = Button(act) button.text = "Say Hello" button.setOnClickListener { Toast.makeText(act, "Hello, ${name.text}!", Toast.LENGTH_SHORT)
 .show() } layout.addView(name) layout.addView(button)
  2. 5IFSFJTOP fun Activity.verticalLayout(init: _LinearLayout.()->Unit): LinearLayout fun ViewManager.button(text: CharSequence?, init: Button.()->Unit):

    Button verticalLayout { val name = editText() button("Say Hello") { onClick { toast("Hello, ${name.text}!") } } }
  3. 5IFUIJTLFZXPSEDPSSFTQPOETUP@-JOFBS-BZPVU 5IFSFJTOP fun Activity.verticalLayout(init: _LinearLayout.()->Unit): LinearLayout fun ViewManager.button(text: CharSequence?, init:

    Button.()->Unit): Button verticalLayout { val name = editText() button("Say Hello") { onClick { toast("Hello, ${name.text}!") } } }
  4. 5IFUIJTLFZXPSEDPSSFTQPOETUP#VUUPO 5IFSFJTOP fun Activity.verticalLayout(init: _LinearLayout.()->Unit): LinearLayout fun ViewManager.button(text: CharSequence?, init:

    Button.()->Unit): Button verticalLayout { val name = editText() button("Say Hello") { onClick { toast("Hello, ${name.text}!") } } }