class MainActivity : AppCompatActivity()
{
override fun onCreate(savedInstanceState: Bundle?)
{ super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
} var name:EditText? = null
fun createBirthdayCard(view: View) {
name = findViewById(R.id.NameInput)
val intent = Intent(this,BirthdayGreetActivity::class.java)
intent.putExtra(BirthdayGreetActivity.NAME_EXTRA,name)
startActivity(intent)
}
}
CodePudding user response:
when sending data
intent.putExtra("name",name)
when receiving data
val name= intent.getStringExtra("name").toString()
CodePudding user response:
intent.putExtra(BirthdayGreetActivity.NAME_EXTRA,name)
this line of yours adds NameInput to intent not string. I dont know what your NameInput is but you may try name.text. Maybe if you gave the code of NameInput I might help better.