Hi all! What's would be the best practice to check...
# android
m
Hi all! What's would be the best practice to check if all editText are empty or blank? In "onCreate" I wrote an if statement and that works but.. I have several editText to check and put an if statement for everyone of them seems way to much code and not in the right place. So, I have this: on setOnClickListener I check if edidTxtDistance is empty, if it's not I execute my funtion else I popup a Toast Message. I have 5 more edixText fields... how to manage it? Thank you!!
Copy code
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    binding = ActivityMainBinding.inflate(layoutInflater)
    setContentView(binding.root)
    
    binding.btnCalculatePace.setOnClickListener {
        if (binding.editTxtDistance.text.toString().trim().isNotEmpty() || binding.editTxtDistance.text.toString().trim().isNotBlank()) {
            (findPace())
        } else {
            Toast.makeText(this, "Please fill all fields", Toast.LENGTH_LONG).show()
        }
    }
}