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

chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...srsj9000
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 

Recently uploaded (20)

chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
Gfe Mayur Vihar Call Girls Service WhatsApp -> 9999965857 Available 24x7 ^ De...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 

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() } } }