Button b = (Button) findViewById(R.id.button);
b.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Your business logic
}
});
"OESPJE+BWB %FGBVMU
⼡せؙٓأ⢪גٔأش٦إحزׅךדن؎ٓ٦فٖ٦زָ㢳ְ
Slide 14
Slide 14 text
Button b = (Button) findViewById(R.id.button);
b.setOnClickListener(view —> {
// Your business logic
});
"OESPJE+BWB -BNCEB
4JOHMF"CTUSBDU.FUIPEכ-BNCEB䒭⢪ֲֿהדأحؗٔה剅ֽ
Slide 15
Slide 15 text
val b = findViewById(R.id.button) as Button
b.setOnClickListener { view ->
// Your business logic
}
b.setOnClickListener { _ ->
// No use args
}
b.setOnClickListener {
//“it” is View
}
,PUMJO
,PUMJOדずׄ״ֲח剅ֽ
⢪זְ䒷侧כ@ד邌ׅ
䒷侧ָאזל
ˑJU˒ؗ٦ٙ٦سד撑
ֿׅהדֹ
,PUMJO أ؝٦فꟼ侧
var test: String? = null
var result: String = text ?: run {
// Some processing
"Hello, world"
}
ٕؒؽأ怴皾㶨ה穈さׇג䊩鴟ָOVMMך㜥さך⦼
⡦ַךⳢ椚ה穈さׇג《䖤דֹ
˟+BWB4DSJQUך⽯儗ꟼ侧䠬鋙
Slide 20
Slide 20 text
+BWB
public class StringUtils {
public static boolean isNothing(String text) {
return text == null || text.isEmpty();
}
}
OVMMתכ瑞俑㶵ַוֲַثؑحؙ׃ְ
Slide 21
Slide 21 text
,PUMJO DMBTT
PCKFDU
class StringUtils {
companion object {
fun isNothing(text: String?): Boolean {
return text == null || text.isEmpty()
}
}
}
object StringUtils {
fun isNothing(text: String?): Boolean {
return text == null || text.isEmpty()
}
}
TUBUJDًاحسך״ֲח鋅ׇ
ˑPCKFDU˒⢪גءؚٕٝزٝד㹀纏ׅ
Slide 22
Slide 22 text
,PUMJO 䭁䓸ꟼ侧
fun String.isNothing(): Boolean =
this == null || this.isEmpty()
var test: String? = null
test.isNothing() // true
㢌侧ך⚥魦ָˑOVMM˒ד/1&搀׃חثؑحָؙדֹ
Slide 23
Slide 23 text
תכծؽٕز؎ׁٝגְך⢪ֲ
@kotlin.internal.InlineOnly
public inline fun CharSequence?.isNullOrEmpty(): Boolean =
this == null || this.length == 0
俑㶵ךOVMMתכˑ瑞˒俑㶵ثؑحָؙדֹ
@kotlin.internal.InlineOnly
public inline fun CharSequence?.isNullOrBlank(): Boolean =
this == null || this.isBlank()
俑㶵ךOVMMתכˑ瑞涯˒俑㶵ثؑحָؙדֹ
Slide 24
Slide 24 text
+BWB JG俑
String text = "This is java";
String result;
if (text.length % 2 == 0) {
result = "Even";
} else {
result = "Odd";
}
JGˑ俑˒
㢌侧㹀纏ךة؎ىؚٝד
⦼然㹀דֹזְ
Slide 25
Slide 25 text
,PUMJO JG䒭
val text = "This is Kotlin"
val result = if (text.length % 2 == 0) {
"Even"
} else {
"Odd"
}
JGˑ䒭˒ה׃ג⦼鵤⽱ֿׅהָדֹךד
㢌侧㹑鎉儗ח⦼然㹀ׇׁ
JGFMTFぐـٗحؙך剑䖓ך遤ָ鐰⣣ׁ