import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.text.InputType
import android.widget.Button
import android.widget.EditText
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Declaring and initializing the EditText
// and Buttons from the layout file
val mEditText = findViewById(R.id.edit_text)
val mTextBtn = findViewById
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.text.InputType
import android.widget.Button
import android.widget.EditText
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
// Declaring and initializing the EditText
// and Buttons from the layout file
val mEditText = findViewById(R.id.edit_text)
val mTextBtn = findViewById(R.id.textBtn)
val mNumBtn = findViewById(R.id.numBtn)
// When this button is clicked, the
// EditText input type will change to Text
mTextBtn.setOnClickListener {
mEditText.inputType = InputType.TYPE_CLASS_TEXT
}
// When this button is clicked, the
// EditText input type will change to Numbers
mNumBtn.setOnClickListener {
mEditText.inputType = InputType.TYPE_CLASS_NUMBER
}
}
}