SlideShare a Scribd company logo
1 of 189
Download to read offline


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/
apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="jp.watanave.ankosamples.XMLActivity">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SAY hello"/>
</LinearLayout>
verticalLayout {
editText()
button("Say Hello")
}
<LinearLayout xmlns:android="http://schemas.android.com/
apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="jp.watanave.ankosamples.XMLActivity">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="SAY hello"/>
</LinearLayout>
verticalLayout {
editText()
button("Say Hello")
}
<LinearLayout >
<EditText/>
<Button/>
</LinearLayout>
verticalLayout {
editText()
button("Say Hello")
}
<LinearLayout >
<EditText/>
<Button/>
</LinearLayout>
verticalLayout {
editText()
button("Say Hello")
}
<LinearLayout >
<EditText/>
<Button/>
</LinearLayout>
verticalLayout {
editText()
button("Say Hello")
}
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:background="@android:color/darker_gray"
tools:context="jp.watanave.ankosamples.XMLActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/red"
android:textColor="#FF0000"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/white"
android:textColor="#FFFFFF"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/yellow"
android:textColor="#FFFB00"/>
</LinearLayout>
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
textView {
text = “ "
textColor = Color.RED
}
textView {
text = “ "
textColor = Color.RED
}
view {
=
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}.lparams {
margin = dip(10)
}
textView {
text = " "
textColor = Color.WHITE
}.lparams {
margin = dip(10)
}
textView {
text = " "
textColor = Color.YELLOW
}.lparams {
margin = dip(10)
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}.lparams {
margin = dip(10)
}
textView {
text = " "
textColor = Color.WHITE
}.lparams {
margin = dip(10)
}
textView {
text = " "
textColor = Color.YELLOW
}.lparams {
margin = dip(10)
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}.lparams {
margin = dip(10)
}
textView {
text = " "
textColor = Color.WHITE
}.lparams {
margin = dip(10)
}
textView {
text = " "
textColor = Color.YELLOW
}.lparams {
margin = dip(10)
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}.lparams {
margin = dip(10)
}
textView {
text = " "
textColor = Color.WHITE
}.lparams {
margin = dip(10)
}
textView {
text = " "
textColor = Color.YELLOW
}.lparams {
margin = dip(10)
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}.lparams {
margin = dip(10)
}
textView {
text = " "
textColor = Color.WHITE
}.lparams {
margin = dip(10)
}
textView {
text = " "
textColor = Color.YELLOW
}.lparams {
margin = dip(10)
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}.lparams {
margin = dip(10)
}
textView {
text = " "
textColor = Color.WHITE
}.lparams {
margin = dip(10)
}
textView {
text = " "
textColor = Color.YELLOW
}.lparams {
margin = dip(10)
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}.lparams {
margin = dip(10)
}
textView {
text = " "
textColor = Color.WHITE
}.lparams {
margin = dip(10)
}
textView {
text = " "
textColor = Color.YELLOW
}.lparams {
margin = dip(10)
}
}
textView {
text = " "
textColor = Color.RED
}.lparams {
margin = dip(10)
}
textView {
text = " "
textColor = Color.RED
}.lparams {
margin = dip(10)
}
view {
}.lparams {
LayoutParams =
}
interface AnkoComponent<in T> {
fun createView(ui: AnkoContext<T>): View
}
class MyActivity : AppCompatActivity() {
//
}
class MyActivity : AppCompatActivity() {
//
}
class MyActivityUI : AnkoComponent<MyActivity> {
}
class MyActivity : AppCompatActivity() {
//
}
class MyActivityUI : AnkoComponent<MyActivity> {
}
class MyActivity : AppCompatActivity() {
//
}
class MyActivityUI : AnkoComponent<MyActivity> {
}
class MyActivity : AppCompatActivity() {
//
}
class MyActivityUI : AnkoComponent<MyActivity> {
override fun createView(ui: AnkoContext<MyActivity>): View {
// DSL
}
}
class MyActivity : AppCompatActivity() {
//
}
class MyActivityUI : AnkoComponent<MyActivity> {
override fun createView(ui: AnkoContext<MyActivity>): View {
// DSL
}
}
class MyActivity : AppCompatActivity() {
//
}
class MyActivityUI : AnkoComponent<MyActivity> {
override fun createView(ui: AnkoContext<MyActivity>): View {
// DSL
}
}
class MyActivity : AppCompatActivity() {
//
}
class MyActivityUI : AnkoComponent<MyActivity> {
override fun createView(ui: AnkoContext<MyActivity>): View {
// DSL
}
}
class MyActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
}
class MyActivityUI : AnkoComponent<MyActivity> {
override fun createView(ui: AnkoContext<MyActivity>): View {
// DSL
}
}
class MyActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
}
}
class MyActivityUI : AnkoComponent<MyActivity> {
override fun createView(ui: AnkoContext<MyActivity>): View {
// DSL
}
}
class MyActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
MyActivityUI().setContentView(this)
}
}
class MyActivityUI : AnkoComponent<MyActivity> {
override fun createView(ui: AnkoContext<MyActivity>): View {
// DSL
}
}
class MyActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
MyActivityUI().setContentView(this)
}
}
class MyActivityUI : AnkoComponent<MyActivity> {
override fun createView(ui: AnkoContext<MyActivity>): View {
// DSL
}
}
class MyActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
MyActivityUI().setContentView(this)
}
}
class MyActivityUI : AnkoComponent<MyActivity> {
override fun createView(ui: AnkoContext<MyActivity>): View {
// DSL
}
}
!
"
#
$
%
&
'
(
)
*
*
( ) ->
val lambda:( ) -> = { ->
// doSomething
}
val result = lambda(arg)
val lambda : (String)->Int = { str ->
val count = str.count()
count //
}
val result = lambda(“DroidKaigi2018")
// 14
( ) ->
val lambda : (String)->Int = { str ->
val count = str.count()
count //
}
val result = lambda(“DroidKaigi2018")
// 14
val array = (0..10)
array.forEach({ num ->
print(num)
})
val array = (0..10)
array.forEach({ num ->
print(num)
})
val array = (0..10)
array.forEach(
print(num)
})
({ num ->
val array = (0..10)
array.forEach(
print(num)
}
)( { num ->
val array = (0..10)
array.forEach() { num ->
print(num)
}
val array = (0..10)
array.forEach() { num ->
print(num)
}
val array = (0..10)
array.forEach() { num ->
print(num)
}
val array = (0..10)
array.forEach() { num ->
print(num)
}
val array = (0..10)
array.forEach() { num ->
print(num)
}
val array = (0..10)
array.forEach { num ->
print(num)
}
array.forEach { num ->
print(num)
}
array.forEach { num ->
print(num)
}
linearLayout {
// doSomething
}
"
linearLayout {
// doSomething
}
linearLayout
this
class MyClass {
fun createTextView() : TextView {
return TextView(context)
}
}
class MyClass {
fun createTextView(argLambda: ()->Unit) : TextView {
return TextView(context)
}
}
class MyClass {
fun createTextView(argLambda: ()->Unit) : TextView {
return TextView(context)
}
fun doSomething() {
createTextView ({
// do something
})
}
}
class MyClass {
fun createTextView(argLambda: ()->Unit) : TextView {
return TextView(context)
}
fun doSomething() {
createTextView ({
// do something
})
}
}
class MyClass {
fun createTextView(argLambda: ()->Unit) : TextView {
return TextView(context)
}
fun doSomething() {
createTextView ({
// do something
})
}
}
class MyClass {
fun createTextView(argLambda: (TextView)->Unit) : TextView {
return TextView(context)
}
fun doSomething() {
createTextView {
// do something
}
}
}
class MyClass {
fun createTextView(argLambda: (TextView)->Unit) : TextView {
val view = TextView(context)
argLambda(view)
return view
}
fun doSomething() {
createTextView {
// do something
}
}
}
class MyClass {
fun createTextView(argLambda: (TextView)->Unit) : TextView {
val view = TextView(context)
argLambda(view)
return view
}
fun doSomething() {
createTextView { textView ->
textView.text = " "
}
}
}
class MyClass {
fun createTextView(argLambda: (TextView)->Unit) : TextView {
val view = TextView(context)
argLambda(view)
return view
}
fun doSomething() {
createTextView { textView ->
textView.text = " "
}
}
}
class MyClass {
fun createTextView(argLambda: (TextView)->Unit) : TextView {
val view = TextView(context)
argLambda(view)
return view
}
fun doSomething() {
createTextView { textView ->
textView.text = " "
}
}
}
class MyClass {
fun createTextView(argLambda: (TextView)->Unit) : TextView {
val view = TextView(context)
argLambda(view)
return view
}
fun doSomething() {
createTextView { textView ->
textView.text = " "
}
}
}
createTextView { textView ->
textView.text = “ "
}
createTextView { textView ->
textView.text = " "
}
textView {
text = " "
}
createTextView { textView ->
textView.text = " "
}
textView {
this.text = " "
this is TextView // true
}
fun createTextView(argLambda: (TextView)->Unit) : TextView {
val view = TextView(context)
argLambda(view)
return view
}
.( ) ->
( ) ->
+
this .( ) ->
( ) ->
+
fun createTextView(argLambda: (TextView)->Unit) : TextView {
val view = TextView(context)
argLambda(view)
return view
}
.( ) ->
( ) ->
+
fun createTextView(argLambda: (TextView)->Unit) : TextView {
val view = TextView(context)
argLambda(view)
return view
}
.( ) ->
( ) ->
+
fun createTextView(argLambda: (TextView)->Unit) : TextView {
val view = TextView(context)
argLambda(view)
return view
}
.( ) ->
( ) ->
+
fun createTextView(argLambda: TextView.()->Unit) : TextView {
val view = TextView(context)
argLambda(view)
return view
}
.( ) ->
( ) ->
+
fun createTextView(argLambda: TextView.()->Unit) : TextView {
val view = TextView(context)
view.argLambda()
return view
}
class MyClass {
fun createTextView(argLambda: TextView.()->Unit) : TextView {
val view = TextView(context)
view.argLambda()
return view
}
fun doSomething() {
createTextView {
text = " "
this is TextView // true
}
}
}
class MyClass {
fun createTextView(argLambda: TextView.()->Unit) : TextView {
val view = TextView(context)
view.argLambda()
return view
}
fun doSomething() {
createTextView {
text = " "
this is TextView // true
}
}
}
class MyClass {
fun createTextView(argLambda: TextView.()->Unit) : TextView {
val view = TextView(context)
view.argLambda()
return view
}
fun doSomething() {
createTextView {
text = " "
this is TextView // true
}
}
}
+
fun lparams() {
// do something
}
+
fun TextView.lparams() {
// do something
}
class MyClass {
fun createTextView(argLambda: TextView.()->Unit) : TextView {
val view = TextView(context)
view.argLambda()
return view
}
fun doSomething() {
val textView = createTextView {
text = " "
}
textView.lparams()
}
}
class MyClass {
fun TextView.lparams() {
this is TextView // true
}
fun createTextView(argLambda: TextView.()->Unit) : TextView {
val view = TextView(context)
view.argLambda()
return view
}
fun doSomething() {
val textView = createTextView {
text = " "
}
textView.lparams()
}
}
class MyClass {
fun createTextView(argLambda: TextView.()->Unit) : TextView {
val view = TextView(context)
view.argLambda()
return view
}
fun doSomething() {
val textView = createTextView {
text = " "
}
textView.lparams()
}
}
class MyClass {
fun TextView.lparams() {
this is TextView // true
}
fun createTextView(argLambda: TextView.()->Unit) : TextView {
val view = TextView(context)
view.argLambda()
return view
}
fun doSomething() {
val textView = createTextView {
text = " "
}
textView.lparams()
}
}
class MyClass {
fun createTextView(argLambda: TextView.()->Unit) : TextView {
val view = TextView(context)
view.argLambda()
return view
}
fun doSomething() {
val textView = createTextView {
text = " "
}
textView.lparams()
}
}
class MyClass {
fun TextView.lparams() {
// do something
}
fun createTextView(argLambda: TextView.()->Unit) : TextView {
val view = TextView(context)
view.argLambda()
return view
}
fun doSomething() {
val textView = createTextView {
text = " "
}
textView.lparams()
}
}
class MyClass {
fun createTextView(argLambda: TextView.()->Unit) : TextView {
val view = TextView(context)
view.argLambda()
return view
}
fun doSomething() {
val textView = createTextView {
text = " "
}
textView.lparams()
}
}
class MyClass {
fun TextView.lparams() {
// do something
}
fun createTextView(argLambda: TextView.()->Unit) : TextView {
val view = TextView(context)
view.argLambda()
return view
}
fun doSomething() {
val textView = createTextView {
text = " "
}
textView.lparams()
}
}
class MyClass {
fun TextView.lparams() {
// do something
}
fun createTextView(argLambda: TextView.()->Unit) : TextView {
val view = TextView(context)
view.argLambda()
return view
}
fun doSomething() {
val textView = createTextView {
text = " "
}
textView.lparams()
}
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) {
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
}
override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) {
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
}
override fun createView(ui: AnkoContext<MyActivity>): View
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
}
override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) {
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
}
override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) {
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
}
override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) {
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
}
inline fun <T, R> with(receiver: T, block: T.() -> R): R (source)
inline fun <T, R> with(receiver: T, block: T.() -> R): R (source)
override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) {
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
}
override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) {
return ui.linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
textView {
text = " "
textColor = Color.WHITE
}
textView {
text = " "
textColor = Color.YELLOW
}
}
}
inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout {
val context = this.ctx
val view = LinearLayout(context)
view.init()
(context as Activity).setContentView(view)
return view
}
override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) {
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
//
}
}
inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout {
val context = this.ctx
val view = LinearLayout(context)
view.init()
(context as Activity).setContentView(view)
return view
}
override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) {
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
//
}
}
inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout {
val context = this.ctx
val view = LinearLayout(context)
view.init()
(context as Activity).setContentView(view)
return view
}
override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) {
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
//
}
}
inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout {
val context = this.ctx
val view = LinearLayout(context)
view.init()
(context as Activity).setContentView(view)
return view
}
override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) {
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
//
}
}
inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout {
val context = this.ctx
val view = LinearLayout(context)
view.init()
(context as Activity).setContentView(view)
return view
}
override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) {
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
//
}
}
inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout {
val context = this.ctx
val view = LinearLayout(context)
view.init()
(context as Activity).setContentView(view)
return view
}
override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) {
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
//
}
} .( ) ->
inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout {
val context = this.ctx
val view = LinearLayout(context)
view.init()
(context as Activity).setContentView(view)
return view
}
override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) {
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
//
}
}
.( ) ->
inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout {
val context = this.ctx
val view = LinearLayout(context)
view.init()
(context as Activity).setContentView(view)
return view
}
override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) {
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
//
}
}
inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout {
val context = this.ctx
val view = LinearLayout(context)
view.init()
(context as Activity).setContentView(view)
return view
}
override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) {
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
//
}
}
inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout {
val context = this.ctx
val view = LinearLayout(context)
view.init()
(context as Activity).setContentView(view)
return view
}
override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) {
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
//
}
}
inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout {
val context = this.ctx
val view = LinearLayout(context)
view.init()
(context as Activity).setContentView(view)
return view
}
override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) {
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}
//
}
}
inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout {
val context = this.ctx
val view = LinearLayout(context)
view.init()
(context as Activity).setContentView(view)
return view
}
_LinearLayout
class _LinearLayout(context: Context) : LinearLayout(context) {
fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView {
val layoutParams = LinearLayout.LayoutParams(width, height)
layoutParams.init()
this.layoutParams = layoutParams
return this
}
}
class _LinearLayout(context: Context) : LinearLayout(context) {
fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView {
val layoutParams = LinearLayout.LayoutParams(width, height)
layoutParams.init()
this.layoutParams = layoutParams
return this
}
}
class _LinearLayout(context: Context) : LinearLayout(context) {
fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView {
val layoutParams = LinearLayout.LayoutParams(width, height)
layoutParams.init()
this.layoutParams = layoutParams
return this
}
}
class _LinearLayout(context: Context) : LinearLayout(context) {
fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView {
val layoutParams = LinearLayout.LayoutParams(width, height)
layoutParams.init()
this.layoutParams = layoutParams
return this
}
}
class _LinearLayout(context: Context) : LinearLayout(context) {
fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView {
val layoutParams = LinearLayout.LayoutParams(width, height)
layoutParams.init()
this.layoutParams = layoutParams
return this
}
}
class _LinearLayout(context: Context) : LinearLayout(context) {
fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView {
val layoutParams = LinearLayout.LayoutParams(width, height)
layoutParams.init()
this.layoutParams = layoutParams
return this
}
}
class _LinearLayout(context: Context) : LinearLayout(context) {
fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView {
val layoutParams = LinearLayout.LayoutParams(width, height)
layoutParams.init()
this.layoutParams = layoutParams
return this
}
}
class _LinearLayout(context: Context) : LinearLayout(context) {
fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView {
val layoutParams = LinearLayout.LayoutParams()
layoutParams.init()
this.layoutParams = layoutParams
return this
}
}
class _LinearLayout(context: Context) : LinearLayout(context) {
fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView {
val layoutParams = LinearLayout.LayoutParams()
layoutParams.init()
this.layoutParams = layoutParams
return this
}
}
class _LinearLayout(context: Context) : LinearLayout(context) {
fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView {
val layoutParams = LinearLayout.LayoutParams()
layoutParams.init()
this.layoutParams = layoutParams
return this
}
}
class _LinearLayout(context: Context) : LinearLayout(context) {
fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView {
val layoutParams = LinearLayout.LayoutParams()
layoutParams.init()
this.layoutParams = layoutParams
return this
}
}
class _LinearLayout(context: Context) : LinearLayout(context) {
fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView {
val layoutParams = LinearLayout.LayoutParams()
layoutParams.init()
this.layoutParams = layoutParams
return this
}
}
class _LinearLayout(context: Context) : LinearLayout(context) {
fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView {
val layoutParams = LinearLayout.LayoutParams()
layoutParams.init()
this.layoutParams = layoutParams
return this
}
}
class _LinearLayout(context: Context) : LinearLayout(context) {
fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView {
val layoutParams = LinearLayout.LayoutParams()
layoutParams.init()
this.layoutParams = layoutParams
return this
}
}
class _LinearLayout(context: Context) : LinearLayout(context) {
fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView {
val layoutParams = LinearLayout.LayoutParams()
layoutParams.init()
this.layoutParams = layoutParams
return this
}
}
class _FrameLayout(context: Context) : FrameLayout(context) {
fun TextView.lparams(init: FrameLayout.LayoutParams.() -> Unit): TextView {
class _RelativeLayout(context: Context) : RelativeLayout(context) {
fun TextView.lparams(init: RelativeLayout.LayoutParams.() -> Unit): TextView {
class _LinearLayout(context: Context) : LinearLayout(context) {
fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView {
class _FrameLayout(context: Context) : FrameLayout(context) {
fun TextView.lparams(init: FrameLayout.LayoutParams.() -> Unit): TextView {
class _RelativeLayout(context: Context) : RelativeLayout(context) {
fun TextView.lparams(init: RelativeLayout.LayoutParams.() -> Unit): TextView {
class _LinearLayout(context: Context) : LinearLayout(context) {
fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView {
class _LinearLayout(context: Context) : LinearLayout(context) {
fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView {
class _FrameLayout(context: Context) : FrameLayout(context) {
fun TextView.lparams(init: FrameLayout.LayoutParams.() -> Unit): TextView {
class _RelativeLayout(context: Context) : RelativeLayout(context) {
fun TextView.lparams(init: RelativeLayout.LayoutParams.() -> Unit): TextView {
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}.lparams {
weight = 1.0f
// this LayoutParams ,
}
//
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}.lparams {
weight = 1.0f
}
//
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}.lparams {
weight = 1.0f
}
//
}
linearLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}.lparams {
weight = 1.0f
}
//
}
relativeLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}.lparams {
centerInParent()
}
//
}
relativeLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}.lparams {
centerInParent()
}
//
}
relativeLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}.lparams {
centerInParent()
}
//
}
relativeLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}.lparams {
centerInParent()
}
//
}
relativeLayout {
backgroundColor = Color.DKGRAY
textView {
text = " "
textColor = Color.RED
}.lparams {
centerInParent()
}
//
}
<TextView
android:layout_centerInParent="true"/>
class MyActivityUI : AnkoComponent<MyActivity> {
override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) {
verticalLayout {
editText {
id = View.generateViewId()
}
button("OK") {
id = View.generateViewId()
}
}
}
}
class MyActivityUI : AnkoComponent<MyActivity> {
override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) {
verticalLayout {
editText {
id = View.generateViewId()
}
button("OK") {
id = View.generateViewId()
}
}
}
}
inline fun generateViewId(): Int = Throwable().stackTrace.first().lineNumber
class MyActivityUI : AnkoComponent<MyActivity> {
override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) {
verticalLayout {
editText {
id = generateViewId()
}
button("OK") {
id = generateViewId()
}
}
}
}
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
inline fun generateViewId(): Int = Throwable().stackTrace.first().lineNumber
class MyActivityUI : AnkoComponent<MyActivity> {
override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) {
verticalLayout {
editText {
id = generateViewId()
}
button("OK") {
id = generateViewId()
}
}
}
}
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
inline fun viewIdFromLineNumber(): Int =
Throwable().stackTrace.first().lineNumber
class MyActivityUI : AnkoComponent<MyActivity> {
override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) {
verticalLayout {
editText {
id = viewIdFromLineNumber()
}
button("OK") {
id = viewIdFromLineNumber()
}
}
}
}
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-
-
linearLayout {
(0..5).forEach {
textView {
id = viewIdFromLineNumber()
}
}
}
Anko試食会

More Related Content

What's hot

Single Page Web Apps with Backbone.js and Rails
Single Page Web Apps with Backbone.js and RailsSingle Page Web Apps with Backbone.js and Rails
Single Page Web Apps with Backbone.js and RailsPrateek Dayal
 
Componentization css angular
Componentization css angularComponentization css angular
Componentization css angularDavid Amend
 
网站无障碍阅读知识
网站无障碍阅读知识网站无障碍阅读知识
网站无障碍阅读知识ppanyong
 
Html5 appunti.0
Html5   appunti.0Html5   appunti.0
Html5 appunti.0orestJump
 
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile EventHTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile EventRobert Nyman
 
05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & Animation05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & AnimationNguyen Tuan
 
Creating web api and consuming part 2
Creating web api and consuming part 2Creating web api and consuming part 2
Creating web api and consuming part 2Dipendra Shekhawat
 
Your Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckYour Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckAnthony Montalbano
 
Html col tag jf
Html col tag jfHtml col tag jf
Html col tag jfjakeed1
 

What's hot (17)

Single Page Web Apps with Backbone.js and Rails
Single Page Web Apps with Backbone.js and RailsSingle Page Web Apps with Backbone.js and Rails
Single Page Web Apps with Backbone.js and Rails
 
Componentization css angular
Componentization css angularComponentization css angular
Componentization css angular
 
网站无障碍阅读知识
网站无障碍阅读知识网站无障碍阅读知识
网站无障碍阅读知识
 
Profit statement 00
Profit statement 00Profit statement 00
Profit statement 00
 
Html5 appunti.0
Html5   appunti.0Html5   appunti.0
Html5 appunti.0
 
Theme
ThemeTheme
Theme
 
Form
FormForm
Form
 
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile EventHTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
HTML5 and CSS3: Exploring Mobile Possibilities - London Ajax Mobile Event
 
HTML and CSS part 2
HTML and CSS part 2HTML and CSS part 2
HTML and CSS part 2
 
[ HackFest.pl 2012] Testing - what for and how
[ HackFest.pl 2012] Testing - what for and how[ HackFest.pl 2012] Testing - what for and how
[ HackFest.pl 2012] Testing - what for and how
 
05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & Animation05.Blend Expression, Transformation & Animation
05.Blend Expression, Transformation & Animation
 
Insertcustomer
InsertcustomerInsertcustomer
Insertcustomer
 
Creating web api and consuming part 2
Creating web api and consuming part 2Creating web api and consuming part 2
Creating web api and consuming part 2
 
Your Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages SuckYour Custom WordPress Admin Pages Suck
Your Custom WordPress Admin Pages Suck
 
Backbone - TDC 2011 Floripa
Backbone - TDC 2011 FloripaBackbone - TDC 2011 Floripa
Backbone - TDC 2011 Floripa
 
Html Tags
Html TagsHtml Tags
Html Tags
 
Html col tag jf
Html col tag jfHtml col tag jf
Html col tag jf
 

Similar to Anko試食会

Advance Android application development workshop day 2
Advance Android application development workshop day 2Advance Android application development workshop day 2
Advance Android application development workshop day 2cresco
 
Working with Javascript in Rails
Working with Javascript in RailsWorking with Javascript in Rails
Working with Javascript in RailsSeungkyun Nam
 
ListView and Custom ListView on Android Development [Thai]
ListView and Custom ListView on Android Development [Thai]ListView and Custom ListView on Android Development [Thai]
ListView and Custom ListView on Android Development [Thai]Somkiat Khitwongwattana
 
Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015 Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015 Mario Jorge Pereira
 
SE2016 Android Mikle Anokhin "Speed up application development with data bind...
SE2016 Android Mikle Anokhin "Speed up application development with data bind...SE2016 Android Mikle Anokhin "Speed up application development with data bind...
SE2016 Android Mikle Anokhin "Speed up application development with data bind...Inhacking
 
Infinum Android Talks #16 - How to shoot your self in the foot by Dino Kovac
Infinum Android Talks #16 - How to shoot your self in the foot by Dino KovacInfinum Android Talks #16 - How to shoot your self in the foot by Dino Kovac
Infinum Android Talks #16 - How to shoot your self in the foot by Dino KovacInfinum
 
Workshop 25: React Native - Components
Workshop 25: React Native - ComponentsWorkshop 25: React Native - Components
Workshop 25: React Native - ComponentsVisual Engineering
 
Connect.js - Exploring React.Native
Connect.js - Exploring React.NativeConnect.js - Exploring React.Native
Connect.js - Exploring React.Nativejoshcjensen
 
Jetpack Compose - A Lightning Tour
Jetpack Compose - A Lightning TourJetpack Compose - A Lightning Tour
Jetpack Compose - A Lightning TourMatthew Clarke
 
eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017
eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017
eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017eMan s.r.o.
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCpootsbook
 
React Native Workshop - React Alicante
React Native Workshop - React AlicanteReact Native Workshop - React Alicante
React Native Workshop - React AlicanteIgnacio Martín
 
Cheap frontend tricks
Cheap frontend tricksCheap frontend tricks
Cheap frontend tricksambiescent
 
Custom UI Components at Android Only 2011
Custom UI Components at Android Only 2011Custom UI Components at Android Only 2011
Custom UI Components at Android Only 2011Johan Nilsson
 
Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React Robert DeLuca
 

Similar to Anko試食会 (20)

Advance Android application development workshop day 2
Advance Android application development workshop day 2Advance Android application development workshop day 2
Advance Android application development workshop day 2
 
Layouts in android
Layouts in androidLayouts in android
Layouts in android
 
Working with Javascript in Rails
Working with Javascript in RailsWorking with Javascript in Rails
Working with Javascript in Rails
 
Chapter 5 - Layouts
Chapter 5 - LayoutsChapter 5 - Layouts
Chapter 5 - Layouts
 
ListView and Custom ListView on Android Development [Thai]
ListView and Custom ListView on Android Development [Thai]ListView and Custom ListView on Android Development [Thai]
ListView and Custom ListView on Android Development [Thai]
 
Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015 Android por onde começar? Mini Curso Erbase 2015
Android por onde começar? Mini Curso Erbase 2015
 
Android 2
Android 2Android 2
Android 2
 
SE2016 Android Mikle Anokhin "Speed up application development with data bind...
SE2016 Android Mikle Anokhin "Speed up application development with data bind...SE2016 Android Mikle Anokhin "Speed up application development with data bind...
SE2016 Android Mikle Anokhin "Speed up application development with data bind...
 
Infinum Android Talks #16 - How to shoot your self in the foot by Dino Kovac
Infinum Android Talks #16 - How to shoot your self in the foot by Dino KovacInfinum Android Talks #16 - How to shoot your self in the foot by Dino Kovac
Infinum Android Talks #16 - How to shoot your self in the foot by Dino Kovac
 
Workshop 25: React Native - Components
Workshop 25: React Native - ComponentsWorkshop 25: React Native - Components
Workshop 25: React Native - Components
 
Connect.js - Exploring React.Native
Connect.js - Exploring React.NativeConnect.js - Exploring React.Native
Connect.js - Exploring React.Native
 
Jetpack Compose - A Lightning Tour
Jetpack Compose - A Lightning TourJetpack Compose - A Lightning Tour
Jetpack Compose - A Lightning Tour
 
Sencha Touch
Sencha TouchSencha Touch
Sencha Touch
 
eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017
eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017
eMan Dev Meetup: Kotlin For Android (part 03/03) 18.5.2017
 
Backbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVCBackbone.js — Introduction to client-side JavaScript MVC
Backbone.js — Introduction to client-side JavaScript MVC
 
React Native Workshop - React Alicante
React Native Workshop - React AlicanteReact Native Workshop - React Alicante
React Native Workshop - React Alicante
 
Cheap frontend tricks
Cheap frontend tricksCheap frontend tricks
Cheap frontend tricks
 
Custom UI Components at Android Only 2011
Custom UI Components at Android Only 2011Custom UI Components at Android Only 2011
Custom UI Components at Android Only 2011
 
Broadleaf Presents Thymeleaf
Broadleaf Presents ThymeleafBroadleaf Presents Thymeleaf
Broadleaf Presents Thymeleaf
 
Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React Crossing platforms with JavaScript & React
Crossing platforms with JavaScript & React
 

Recently uploaded

DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationBhangaleSonal
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Call Girls Mumbai
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...soginsider
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Servicemeghakumariji156
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptMsecMca
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayEpec Engineered Technologies
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwaitjaanualu31
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086anil_gaur
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...HenryBriggs2
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxSCMS School of Architecture
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projectssmsksolar
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsvanyagupta248
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 

Recently uploaded (20)

DC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equationDC MACHINE-Motoring and generation, Armature circuit equation
DC MACHINE-Motoring and generation, Armature circuit equation
 
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
Bhubaneswar🌹Call Girls Bhubaneswar ❤Komal 9777949614 💟 Full Trusted CALL GIRL...
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best ServiceTamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
Tamil Call Girls Bhayandar WhatsApp +91-9930687706, Best Service
 
notes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.pptnotes on Evolution Of Analytic Scalability.ppt
notes on Evolution Of Analytic Scalability.ppt
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 
Standard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power PlayStandard vs Custom Battery Packs - Decoding the Power Play
Standard vs Custom Battery Packs - Decoding the Power Play
 
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills KuwaitKuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
Kuwait City MTP kit ((+919101817206)) Buy Abortion Pills Kuwait
 
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak HamilCara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
Cara Menggugurkan Sperma Yang Masuk Rahim Biyar Tidak Hamil
 
Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086Minimum and Maximum Modes of microprocessor 8086
Minimum and Maximum Modes of microprocessor 8086
 
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
scipt v1.pptxcxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx...
 
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptxHOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
HOA1&2 - Module 3 - PREHISTORCI ARCHITECTURE OF KERALA.pptx
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects2016EF22_0 solar project report rooftop projects
2016EF22_0 solar project report rooftop projects
 
AIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech studentsAIRCANVAS[1].pdf mini project for btech students
AIRCANVAS[1].pdf mini project for btech students
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced LoadsFEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
FEA Based Level 3 Assessment of Deformed Tanks with Fluid Induced Loads
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
Call Girls in South Ex (delhi) call me [🔝9953056974🔝] escort service 24X7
 

Anko試食会

  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13. <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/ apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="jp.watanave.ankosamples.XMLActivity"> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:text="SAY hello"/> </LinearLayout>
  • 19.
  • 21. linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } }
  • 22. linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } } linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } }
  • 23. linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } } linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } }
  • 24. linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } } linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } } linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED }
  • 25. linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } }
  • 26. linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } }
  • 27. linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } } linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } }
  • 28. linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } } linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } }
  • 29. linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } } linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } } textView { text = “ " textColor = Color.RED }
  • 30. textView { text = “ " textColor = Color.RED }
  • 32. linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } }
  • 33. linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED }.lparams { margin = dip(10) } textView { text = " " textColor = Color.WHITE }.lparams { margin = dip(10) } textView { text = " " textColor = Color.YELLOW }.lparams { margin = dip(10) } }
  • 34. linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED }.lparams { margin = dip(10) } textView { text = " " textColor = Color.WHITE }.lparams { margin = dip(10) } textView { text = " " textColor = Color.YELLOW }.lparams { margin = dip(10) } } linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED }.lparams { margin = dip(10) } textView { text = " " textColor = Color.WHITE }.lparams { margin = dip(10) } textView { text = " " textColor = Color.YELLOW }.lparams { margin = dip(10) } }
  • 35. linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED }.lparams { margin = dip(10) } textView { text = " " textColor = Color.WHITE }.lparams { margin = dip(10) } textView { text = " " textColor = Color.YELLOW }.lparams { margin = dip(10) } } linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED }.lparams { margin = dip(10) } textView { text = " " textColor = Color.WHITE }.lparams { margin = dip(10) } textView { text = " " textColor = Color.YELLOW }.lparams { margin = dip(10) } }
  • 36. linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED }.lparams { margin = dip(10) } textView { text = " " textColor = Color.WHITE }.lparams { margin = dip(10) } textView { text = " " textColor = Color.YELLOW }.lparams { margin = dip(10) } } linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED }.lparams { margin = dip(10) } textView { text = " " textColor = Color.WHITE }.lparams { margin = dip(10) } textView { text = " " textColor = Color.YELLOW }.lparams { margin = dip(10) } } textView { text = " " textColor = Color.RED }.lparams { margin = dip(10) }
  • 37. textView { text = " " textColor = Color.RED }.lparams { margin = dip(10) }
  • 39. interface AnkoComponent<in T> { fun createView(ui: AnkoContext<T>): View }
  • 40. class MyActivity : AppCompatActivity() { // }
  • 41. class MyActivity : AppCompatActivity() { // } class MyActivityUI : AnkoComponent<MyActivity> { }
  • 42. class MyActivity : AppCompatActivity() { // } class MyActivityUI : AnkoComponent<MyActivity> { } class MyActivity : AppCompatActivity() { // } class MyActivityUI : AnkoComponent<MyActivity> { }
  • 43. class MyActivity : AppCompatActivity() { // } class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View { // DSL } }
  • 44. class MyActivity : AppCompatActivity() { // } class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View { // DSL } } class MyActivity : AppCompatActivity() { // } class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View { // DSL } }
  • 45. class MyActivity : AppCompatActivity() { // } class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View { // DSL } }
  • 46. class MyActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) } } class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View { // DSL } }
  • 47. class MyActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) } } class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View { // DSL } }
  • 48. class MyActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) MyActivityUI().setContentView(this) } } class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View { // DSL } }
  • 49. class MyActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) MyActivityUI().setContentView(this) } } class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View { // DSL } } class MyActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) MyActivityUI().setContentView(this) } } class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View { // DSL } }
  • 50.
  • 51.
  • 52.
  • 53.
  • 54.
  • 55. !
  • 56.
  • 57. "
  • 58.
  • 59.
  • 60.
  • 61. #
  • 62.
  • 63. $
  • 64.
  • 65. %
  • 67. *
  • 68.
  • 69.
  • 70.
  • 72. val lambda:( ) -> = { -> // doSomething } val result = lambda(arg)
  • 73. val lambda : (String)->Int = { str -> val count = str.count() count // } val result = lambda(“DroidKaigi2018") // 14 ( ) ->
  • 74. val lambda : (String)->Int = { str -> val count = str.count() count // } val result = lambda(“DroidKaigi2018") // 14
  • 75.
  • 76.
  • 77. val array = (0..10) array.forEach({ num -> print(num) })
  • 78.
  • 79. val array = (0..10) array.forEach({ num -> print(num) })
  • 80. val array = (0..10) array.forEach( print(num) }) ({ num ->
  • 81. val array = (0..10) array.forEach( print(num) } )( { num ->
  • 82. val array = (0..10) array.forEach() { num -> print(num) }
  • 83.
  • 84. val array = (0..10) array.forEach() { num -> print(num) }
  • 85. val array = (0..10) array.forEach() { num -> print(num) }
  • 86. val array = (0..10) array.forEach() { num -> print(num) } val array = (0..10) array.forEach() { num -> print(num) }
  • 87. val array = (0..10) array.forEach { num -> print(num) }
  • 88. array.forEach { num -> print(num) }
  • 89. array.forEach { num -> print(num) } linearLayout { // doSomething } "
  • 91.
  • 92.
  • 93. this
  • 94. class MyClass { fun createTextView() : TextView { return TextView(context) } }
  • 95. class MyClass { fun createTextView(argLambda: ()->Unit) : TextView { return TextView(context) } }
  • 96. class MyClass { fun createTextView(argLambda: ()->Unit) : TextView { return TextView(context) } fun doSomething() { createTextView ({ // do something }) } }
  • 97. class MyClass { fun createTextView(argLambda: ()->Unit) : TextView { return TextView(context) } fun doSomething() { createTextView ({ // do something }) } } class MyClass { fun createTextView(argLambda: ()->Unit) : TextView { return TextView(context) } fun doSomething() { createTextView ({ // do something }) } }
  • 98. class MyClass { fun createTextView(argLambda: (TextView)->Unit) : TextView { return TextView(context) } fun doSomething() { createTextView { // do something } } }
  • 99. class MyClass { fun createTextView(argLambda: (TextView)->Unit) : TextView { val view = TextView(context) argLambda(view) return view } fun doSomething() { createTextView { // do something } } }
  • 100. class MyClass { fun createTextView(argLambda: (TextView)->Unit) : TextView { val view = TextView(context) argLambda(view) return view } fun doSomething() { createTextView { textView -> textView.text = " " } } }
  • 101. class MyClass { fun createTextView(argLambda: (TextView)->Unit) : TextView { val view = TextView(context) argLambda(view) return view } fun doSomething() { createTextView { textView -> textView.text = " " } } }
  • 102. class MyClass { fun createTextView(argLambda: (TextView)->Unit) : TextView { val view = TextView(context) argLambda(view) return view } fun doSomething() { createTextView { textView -> textView.text = " " } } }
  • 103. class MyClass { fun createTextView(argLambda: (TextView)->Unit) : TextView { val view = TextView(context) argLambda(view) return view } fun doSomething() { createTextView { textView -> textView.text = " " } } } createTextView { textView -> textView.text = “ " }
  • 104. createTextView { textView -> textView.text = " " } textView { text = " " }
  • 105. createTextView { textView -> textView.text = " " } textView { this.text = " " this is TextView // true }
  • 106. fun createTextView(argLambda: (TextView)->Unit) : TextView { val view = TextView(context) argLambda(view) return view }
  • 107.
  • 108. .( ) -> ( ) -> +
  • 109. this .( ) -> ( ) -> +
  • 110. fun createTextView(argLambda: (TextView)->Unit) : TextView { val view = TextView(context) argLambda(view) return view } .( ) -> ( ) -> +
  • 111. fun createTextView(argLambda: (TextView)->Unit) : TextView { val view = TextView(context) argLambda(view) return view } .( ) -> ( ) -> +
  • 112. fun createTextView(argLambda: (TextView)->Unit) : TextView { val view = TextView(context) argLambda(view) return view } .( ) -> ( ) -> +
  • 113. fun createTextView(argLambda: TextView.()->Unit) : TextView { val view = TextView(context) argLambda(view) return view } .( ) -> ( ) -> +
  • 114. fun createTextView(argLambda: TextView.()->Unit) : TextView { val view = TextView(context) view.argLambda() return view }
  • 115. class MyClass { fun createTextView(argLambda: TextView.()->Unit) : TextView { val view = TextView(context) view.argLambda() return view } fun doSomething() { createTextView { text = " " this is TextView // true } } }
  • 116. class MyClass { fun createTextView(argLambda: TextView.()->Unit) : TextView { val view = TextView(context) view.argLambda() return view } fun doSomething() { createTextView { text = " " this is TextView // true } } } class MyClass { fun createTextView(argLambda: TextView.()->Unit) : TextView { val view = TextView(context) view.argLambda() return view } fun doSomething() { createTextView { text = " " this is TextView // true } } }
  • 117.
  • 118.
  • 119.
  • 120. + fun lparams() { // do something } + fun TextView.lparams() { // do something }
  • 121. class MyClass { fun createTextView(argLambda: TextView.()->Unit) : TextView { val view = TextView(context) view.argLambda() return view } fun doSomething() { val textView = createTextView { text = " " } textView.lparams() } } class MyClass { fun TextView.lparams() { this is TextView // true } fun createTextView(argLambda: TextView.()->Unit) : TextView { val view = TextView(context) view.argLambda() return view } fun doSomething() { val textView = createTextView { text = " " } textView.lparams() } }
  • 122. class MyClass { fun createTextView(argLambda: TextView.()->Unit) : TextView { val view = TextView(context) view.argLambda() return view } fun doSomething() { val textView = createTextView { text = " " } textView.lparams() } } class MyClass { fun TextView.lparams() { this is TextView // true } fun createTextView(argLambda: TextView.()->Unit) : TextView { val view = TextView(context) view.argLambda() return view } fun doSomething() { val textView = createTextView { text = " " } textView.lparams() } }
  • 123. class MyClass { fun createTextView(argLambda: TextView.()->Unit) : TextView { val view = TextView(context) view.argLambda() return view } fun doSomething() { val textView = createTextView { text = " " } textView.lparams() } } class MyClass { fun TextView.lparams() { // do something } fun createTextView(argLambda: TextView.()->Unit) : TextView { val view = TextView(context) view.argLambda() return view } fun doSomething() { val textView = createTextView { text = " " } textView.lparams() } }
  • 124. class MyClass { fun createTextView(argLambda: TextView.()->Unit) : TextView { val view = TextView(context) view.argLambda() return view } fun doSomething() { val textView = createTextView { text = " " } textView.lparams() } } class MyClass { fun TextView.lparams() { // do something } fun createTextView(argLambda: TextView.()->Unit) : TextView { val view = TextView(context) view.argLambda() return view } fun doSomething() { val textView = createTextView { text = " " } textView.lparams() } } class MyClass { fun TextView.lparams() { // do something } fun createTextView(argLambda: TextView.()->Unit) : TextView { val view = TextView(context) view.argLambda() return view } fun doSomething() { val textView = createTextView { text = " " } textView.lparams() } }
  • 125.
  • 126.
  • 127. linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } }
  • 128. override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } } }
  • 129. override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } } } override fun createView(ui: AnkoContext<MyActivity>): View linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } } }
  • 130. override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } } }
  • 131. override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } } } override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } } }
  • 132. inline fun <T, R> with(receiver: T, block: T.() -> R): R (source)
  • 133. inline fun <T, R> with(receiver: T, block: T.() -> R): R (source)
  • 134. override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) { linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } } }
  • 135. override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) { return ui.linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } textView { text = " " textColor = Color.WHITE } textView { text = " " textColor = Color.YELLOW } } }
  • 136. inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout { val context = this.ctx val view = LinearLayout(context) view.init() (context as Activity).setContentView(view) return view } override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) { linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } // } }
  • 137. inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout { val context = this.ctx val view = LinearLayout(context) view.init() (context as Activity).setContentView(view) return view } override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) { linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } // } }
  • 138. inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout { val context = this.ctx val view = LinearLayout(context) view.init() (context as Activity).setContentView(view) return view } override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) { linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } // } }
  • 139. inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout { val context = this.ctx val view = LinearLayout(context) view.init() (context as Activity).setContentView(view) return view } override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) { linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } // } }
  • 140. inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout { val context = this.ctx val view = LinearLayout(context) view.init() (context as Activity).setContentView(view) return view } override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) { linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } // } }
  • 141. inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout { val context = this.ctx val view = LinearLayout(context) view.init() (context as Activity).setContentView(view) return view } override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) { linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } // } } .( ) ->
  • 142. inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout { val context = this.ctx val view = LinearLayout(context) view.init() (context as Activity).setContentView(view) return view } override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) { linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } // } } .( ) ->
  • 143. inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout { val context = this.ctx val view = LinearLayout(context) view.init() (context as Activity).setContentView(view) return view } override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) { linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } // } }
  • 144. inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout { val context = this.ctx val view = LinearLayout(context) view.init() (context as Activity).setContentView(view) return view } override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) { linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } // } }
  • 145. inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout { val context = this.ctx val view = LinearLayout(context) view.init() (context as Activity).setContentView(view) return view } override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) { linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } // } }
  • 146. inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout { val context = this.ctx val view = LinearLayout(context) view.init() (context as Activity).setContentView(view) return view } override fun createView(ui: AnkoContext<MainActivity>): View = with(ui) { linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED } // } } inline fun AnkoContext<*>.linearLayout(init: LinearLayout.() -> Unit): _LinearLayout { val context = this.ctx val view = LinearLayout(context) view.init() (context as Activity).setContentView(view) return view }
  • 148.
  • 149.
  • 150. class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { val layoutParams = LinearLayout.LayoutParams(width, height) layoutParams.init() this.layoutParams = layoutParams return this } }
  • 151. class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { val layoutParams = LinearLayout.LayoutParams(width, height) layoutParams.init() this.layoutParams = layoutParams return this } }
  • 152. class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { val layoutParams = LinearLayout.LayoutParams(width, height) layoutParams.init() this.layoutParams = layoutParams return this } } class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { val layoutParams = LinearLayout.LayoutParams(width, height) layoutParams.init() this.layoutParams = layoutParams return this } }
  • 153. class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { val layoutParams = LinearLayout.LayoutParams(width, height) layoutParams.init() this.layoutParams = layoutParams return this } }
  • 154. class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { val layoutParams = LinearLayout.LayoutParams(width, height) layoutParams.init() this.layoutParams = layoutParams return this } } class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { val layoutParams = LinearLayout.LayoutParams(width, height) layoutParams.init() this.layoutParams = layoutParams return this } }
  • 155. class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { val layoutParams = LinearLayout.LayoutParams() layoutParams.init() this.layoutParams = layoutParams return this } }
  • 156. class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { val layoutParams = LinearLayout.LayoutParams() layoutParams.init() this.layoutParams = layoutParams return this } }
  • 157. class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { val layoutParams = LinearLayout.LayoutParams() layoutParams.init() this.layoutParams = layoutParams return this } }
  • 158. class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { val layoutParams = LinearLayout.LayoutParams() layoutParams.init() this.layoutParams = layoutParams return this } } class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { val layoutParams = LinearLayout.LayoutParams() layoutParams.init() this.layoutParams = layoutParams return this } }
  • 159. class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { val layoutParams = LinearLayout.LayoutParams() layoutParams.init() this.layoutParams = layoutParams return this } }
  • 160. class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { val layoutParams = LinearLayout.LayoutParams() layoutParams.init() this.layoutParams = layoutParams return this } } class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { val layoutParams = LinearLayout.LayoutParams() layoutParams.init() this.layoutParams = layoutParams return this } }
  • 161. class _FrameLayout(context: Context) : FrameLayout(context) { fun TextView.lparams(init: FrameLayout.LayoutParams.() -> Unit): TextView { class _RelativeLayout(context: Context) : RelativeLayout(context) { fun TextView.lparams(init: RelativeLayout.LayoutParams.() -> Unit): TextView { class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView {
  • 162. class _FrameLayout(context: Context) : FrameLayout(context) { fun TextView.lparams(init: FrameLayout.LayoutParams.() -> Unit): TextView { class _RelativeLayout(context: Context) : RelativeLayout(context) { fun TextView.lparams(init: RelativeLayout.LayoutParams.() -> Unit): TextView { class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { class _LinearLayout(context: Context) : LinearLayout(context) { fun TextView.lparams(init: LinearLayout.LayoutParams.() -> Unit): TextView { class _FrameLayout(context: Context) : FrameLayout(context) { fun TextView.lparams(init: FrameLayout.LayoutParams.() -> Unit): TextView { class _RelativeLayout(context: Context) : RelativeLayout(context) { fun TextView.lparams(init: RelativeLayout.LayoutParams.() -> Unit): TextView {
  • 163. linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED }.lparams { weight = 1.0f // this LayoutParams , } // }
  • 164. linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED }.lparams { weight = 1.0f } // }
  • 165. linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED }.lparams { weight = 1.0f } // } linearLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED }.lparams { weight = 1.0f } // }
  • 166. relativeLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED }.lparams { centerInParent() } // }
  • 167. relativeLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED }.lparams { centerInParent() } // } relativeLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED }.lparams { centerInParent() } // }
  • 168. relativeLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED }.lparams { centerInParent() } // } relativeLayout { backgroundColor = Color.DKGRAY textView { text = " " textColor = Color.RED }.lparams { centerInParent() } // } <TextView android:layout_centerInParent="true"/>
  • 169.
  • 170.
  • 171.
  • 172. class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { verticalLayout { editText { id = View.generateViewId() } button("OK") { id = View.generateViewId() } } } }
  • 173. class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { verticalLayout { editText { id = View.generateViewId() } button("OK") { id = View.generateViewId() } } } }
  • 174.
  • 175.
  • 176.
  • 177.
  • 178.
  • 179.
  • 180.
  • 181.
  • 182.
  • 183.
  • 184. inline fun generateViewId(): Int = Throwable().stackTrace.first().lineNumber class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { verticalLayout { editText { id = generateViewId() } button("OK") { id = generateViewId() } } } } -renamesourcefileattribute SourceFile -keepattributes SourceFile,LineNumberTable
  • 185. inline fun generateViewId(): Int = Throwable().stackTrace.first().lineNumber class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { verticalLayout { editText { id = generateViewId() } button("OK") { id = generateViewId() } } } } -renamesourcefileattribute SourceFile -keepattributes SourceFile,LineNumberTable
  • 186. inline fun viewIdFromLineNumber(): Int = Throwable().stackTrace.first().lineNumber class MyActivityUI : AnkoComponent<MyActivity> { override fun createView(ui: AnkoContext<MyActivity>): View = with(ui) { verticalLayout { editText { id = viewIdFromLineNumber() } button("OK") { id = viewIdFromLineNumber() } } } } -renamesourcefileattribute SourceFile -keepattributes SourceFile,LineNumberTable
  • 187. -
  • 188. - linearLayout { (0..5).forEach { textView { id = viewIdFromLineNumber() } } }