Cast findViewById() result to Views safely
This commit is contained in:
@@ -13,14 +13,14 @@ import android.support.v4.widget.*
|
||||
import kotlin.internal.flexible.ft
|
||||
|
||||
val android.app.Activity.textView1: ft<View, View?>
|
||||
get() = findViewById(0) : View
|
||||
get() = findViewById(0)
|
||||
|
||||
val android.app.Fragment.textView1: ft<View, View?>
|
||||
get() = getView().findViewById(0) : View
|
||||
get() = getView().findViewById(0)
|
||||
|
||||
val android.app.Activity.textView2: ft<TextView, TextView?>
|
||||
get() = findViewById(0) as TextView
|
||||
get() = findViewById(0) as? TextView
|
||||
|
||||
val android.app.Fragment.textView2: ft<TextView, TextView?>
|
||||
get() = getView().findViewById(0) as TextView
|
||||
get() = getView().findViewById(0) as? TextView
|
||||
|
||||
|
||||
+2
-2
@@ -13,8 +13,8 @@ import android.support.v4.widget.*
|
||||
import kotlin.internal.flexible.ft
|
||||
|
||||
val android.view.View.textView1: ft<View, View?>
|
||||
get() = findViewById(0) : View
|
||||
get() = findViewById(0)
|
||||
|
||||
val android.view.View.textView2: ft<TextView, TextView?>
|
||||
get() = findViewById(0) as TextView
|
||||
get() = findViewById(0) as? TextView
|
||||
|
||||
|
||||
Reference in New Issue
Block a user