#struggling to build my first android app
4 messages · Page 1 of 1 (latest)
⌛ This post has been reserved for your question.
Hey @dry steppe! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
package com.example.myapplication
import android.annotation.SuppressLint
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.widget.Button
import android.widget.TextView
import com.google.android.material.textfield.TextInputEditText
class MainActivity : AppCompatActivity() {
@SuppressLint("MissingInflatedId", "SuspiciousIndentation")
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val textInputEditText = findViewById<TextInputEditText>(R.id.textInputEditText)
val textView = findViewById<TextView>(R.id.textView)
val button = findViewById<Button>(R.id.button)
button.setOnClickListener {
val inputText = textInputEditText.text.toString()
textView.text = inputText
}
}
} ```
This message has been formatted automatically. You can disable this using /preferences.