add android xml bridge invocation test
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
package com.myapp
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
|
||||
class MyActivity(): Activity() {
|
||||
val textViewWidget = TextView()
|
||||
val editTextWidget = EditText()
|
||||
val buttonWidget = Button()
|
||||
|
||||
override fun findViewById(id: Int): View? {
|
||||
return when (id) {
|
||||
R.id.textView1 -> textViewWidget
|
||||
R.id.password -> editTextWidget
|
||||
R.id.login -> buttonWidget
|
||||
else -> null
|
||||
}
|
||||
}
|
||||
|
||||
fun test(): String {
|
||||
return if (password.toString() == "EditText" &&
|
||||
textView1.toString() == "TextView" &&
|
||||
login.toString() == "Button" )
|
||||
"OK" else "NOTOK"
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
package com.myapp
|
||||
|
||||
class R {
|
||||
class id {
|
||||
class object {
|
||||
val item_detail_container = 0
|
||||
val textView1 = 0
|
||||
val password = 0
|
||||
val textView2 = 0
|
||||
val passwordConfirmation = 0
|
||||
val login = 0
|
||||
val textView1 = 1
|
||||
val password = 2
|
||||
val textView2 = 3
|
||||
val passwordConfirmation = 4
|
||||
val login = 5
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,18 @@
|
||||
package com.myapp
|
||||
|
||||
import android.app.Activity
|
||||
import android.view.View
|
||||
import android.widget.*
|
||||
|
||||
val Activity.item_detail_container: FrameLayout
|
||||
get() = findViewById(R.id.item_detail_container) as FrameLayout
|
||||
get() = findViewById(0) as FrameLayout
|
||||
|
||||
val Activity.textView1: TextView
|
||||
get() = findViewById(R.id.textView1) as TextView
|
||||
get() = findViewById(0) as TextView
|
||||
|
||||
val Activity.password: EditText
|
||||
get() = findViewById(R.id.password) as EditText
|
||||
get() = findViewById(0) as EditText
|
||||
|
||||
val Activity.login: Button
|
||||
get() = findViewById(R.id.login) as Button
|
||||
get() = findViewById(0) as Button
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package android.app
|
||||
import android.view.View
|
||||
|
||||
trait Activity {
|
||||
fun findViewById(id: Int): View?
|
||||
abstract class Activity {
|
||||
open abstract fun findViewById(id: Int): View?
|
||||
}
|
||||
@@ -1,3 +1,3 @@
|
||||
package android.view
|
||||
|
||||
class View
|
||||
trait View
|
||||
@@ -1,6 +1,16 @@
|
||||
package android.widget
|
||||
|
||||
class EditText
|
||||
class TextView
|
||||
class Button
|
||||
class FrameLayout
|
||||
import android.view.View
|
||||
|
||||
class EditText: View {
|
||||
override fun toString(): String {return "EditText"}
|
||||
}
|
||||
class TextView: View {
|
||||
override fun toString(): String {return "TextView"}
|
||||
}
|
||||
class Button: View {
|
||||
override fun toString(): String {return "Button"}
|
||||
}
|
||||
class FrameLayout: View {
|
||||
override fun toString(): String {return "FrameLayout"}
|
||||
}
|
||||
Reference in New Issue
Block a user