Advertisement
AzisMM

MainActivity.kt

Feb 7th, 2024 (edited)
1,571
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.92 KB | None | 0 0
  1. package com.azis.learn
  2.  
  3. import android.content.Intent
  4. import androidx.appcompat.app.AppCompatActivity
  5. import android.os.Bundle
  6. import android.widget.Button
  7. import android.widget.EditText
  8.  
  9. class MainActivity : AppCompatActivity() {
  10.     override fun onCreate(savedInstanceState: Bundle?) {
  11.         super.onCreate(savedInstanceState)
  12.         setContentView(R.layout.activity_main)
  13.  
  14.         val button : Button = findViewById(R.id.buttonSend)
  15.         val editText : EditText = findViewById(R.id.editTextText)
  16.  
  17.         // Mendapatkan teks dari EditText saat tombol diklik
  18.         button.setOnClickListener {
  19.             val inputText = editText.text.toString()
  20.  
  21.             // Membuat Intent untuk mengirimkan kembali teks ke ActivityA
  22.             val intent = Intent(this, MainActivity2::class.java)
  23.             intent.putExtra("textFromMainActivity2", inputText)
  24.             startActivity(intent)
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement