<pre> class MainActivity : AppCompatActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) val sendDOB = findViewById<EditText>(R.id.InputDOB) val sendbutton = findViewById<Button>(R.id.createBirthdayCardButton) sendbutton.setOnClickListener { val dob = sendDOB.text.toString() val intent = Intent(this, Birthdaycard::class.java) intent.putExtra("DOB", dob) startActivity(intent) } }
<pre>class Birthdaycard : AppCompatActivity() { companion object { const val NAME_EXTRA = "NAME" const val DOB_EXTRA = "DOB" } override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_birthdaycard) val dob = intent.getStringExtra(DOB_EXTRA) val dobTextView = findViewById<TextView>(R.id.outputage) dobTextView.text = dob // calculate and display age, birthstone, and zodiac sign here } }
String[] stones = { "Garnet", "Amethyst", "Aquamarine", "Diamond" ... };
stones[birthMonth - 1];
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)