Question: I have alertdialog input text and i want if edittext is empty get toast " plz fill field " if user click positive button and if edittext is not empty continue open activity 

```
LayoutInflater layoutInflaterAndroid = LayoutInflater.from(newapp.this);
View view = layoutInflaterAndroid.inflate(R.layout.input_dialog, null);
AlertDialog.Builder adb = new AlertDialog.Builder(newapp.this);

adb.setView(view);
name = (EditText) view.findViewById(R.id.name);
password = (EditText) view.findViewById(R.id.password);
adb
        .setCancelable(false)
        .setTitle(getResources().getString(R.string.info))
        .setIcon(R.mipmap.ic_launcher)
        .setPositiveButton(getResources().getString(R.string.start), new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialogBox, int id) {
                 Intent cc = new Intent(StartActivity.this, news.class);
    startActivity(cc);

            }
        })

        .setNegativeButton(getResources().getString(R.string.close),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialogBox, int id) {
                        dialogBox.cancel();
                    }
                });

AlertDialog alertDialogAndroid = adb.create();
alertDialogAndroid.show();

}

```

Answer: 
You can check the length of the text as follows

```
if(name.getText().toString().trim().length() == 0 ){
  //empty
}else{
  //non-empty
}

```
Eh... it is not the place where pepole are writing code for you, but...

```
    .setPositiveButton(getResources().getString(R.string.start), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialogBox, int id) {
           if(!TextUtils.isEmpty(name.getText().toString())                 
               Intent cc = new Intent(StartActivity.this, news.class);
               startActivity(cc);
           } else {
               Toast.makeText(context, "Message", Toast.LENGTH_LONG).show();
           }
        }
    })

```