Global object declaration in kotlin
问题 How to declare objects globally in kotlin like in java TextView tv; . Or any method to call the same variable in different methods/functions. override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val textView: TextView = findViewById(R.id.texfirst) as TextView textView.setOnClickListener { Toast.makeText(applicationContext,"Welcome to Kotlin ! $abc "+textView.text, Toast.LENGTH_LONG).show() } myFunction(textView) } fun