How to add toast message if editText is empty or null android studio

After working and searching for hours and you can’t get the solution you are looking for. You are welcome to the home of Android Developer. If you have

being using Android Studio for writing Java apps, Java codes is everything sensitive raging from capital letters, punctuation errors, misspelled of words and plugin updates.

Display warning message instead of app crash when EditText or EditView is empty and button tapped.  

Android Studio comes up with new updates always which depreciated the older once. A code you write today, use it and develop an app may be outdated and depreciated tomorrow. If you copy somebody’s code or forked a code from github, there are chances that the code which worked earlier won’t work again unless you do serious editing.

In MainActivity Java Class add below codes

public void onClick(View v) {
try {

} catch (Exception e) {
Toast.makeText(getApplicationContext(), “Type a valid number”, Toast.LENGTH_SHORT).show();

or add this on onClick@Override

public void onClick(View v) {


Toast.makeText(MainActivity.this, “Type amount to continue”, Toast.LENGTH_LONG).show();

}else {
//Do the task onClick suppose do