class MainActivity : AppCompatActivity() { private lateinit var binding: ActivityMainBinding private val myName:MyName = MyName("Kotlin noob") override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) binding = DataBindingUtil.setContentView(this, R.layout.activity_main) binding.myName = myName //line 1 binding.doneButton.setOnClickListener { addName(it) } } fun addName(view: View) { myName?.nickName = nickName_edit.text.toString() //line 2 binding.showNameTextView.text = "hello ${binding.enterNameEditText.text}" binding.showNameTextView.visibility = View.VISIBLE binding.enterNameEditText.visibility = View.GONE view.visibility = View.GONE } //this is the class used for data data class MyName(var name:String="", var nickName:String="") }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)