package alphasniper.com.github.edittext;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    EditText basicET;
    Button clickBtn;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        basicET = (EditText) findViewById(R.id.editText);
        clickBtn = (Button) findViewById(R.id.button);

        clickBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(basicET.getText().toString().isEmpty()){
                    basicET.setError("You Didn't Enter anything");

                }
                else {
                    Toast.makeText(MainActivity.this, "Hello !!.. "+ basicET.getText().toString(), Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
}
