In order to create a dialog with an EditText inside, you can do this in the button's OnClickListener:
final FrameLayout fl = new FrameLayout(ContactView.this);
final EditText txtSms = new EditText(ContactView.this);
txtSms.setRawInputType(InputType.TYPE_TEXT_FLAG_MULTI_LINE);
txtSms.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
txtSms.setHorizontallyScrolling(false);
txtSms.setVerticalScrollBarEnabled(true);
txtSms.setGravity(Gravity.CENTER);
fl.addView(txtSms, new FrameLayout.LayoutParams(FrameLayout.LayoutParams.FILL_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT));
    final AlertDialog.Builder builder = new AlertDialog.Builder(ContactView.this);
        //building the custom AlertDialog
        builder.setView(fl).setTitle("Enviar mensaje").setCancelable(false)
        .setPositiveButton("Send", new DialogInterface.OnClickListener(){
                    //What happens when the positive button is pressed
            public void onClick(DialogInterface d, int which){
                if(txtSms.getText().toString().length() != 0){
                    enviarSms(txtSms.getText().toString());
                    d.dismiss();
                }else{
                    Toast.makeText(((Dialog) d).getContext(), "Can't send an empty message", Toast.LENGTH_SHORT).show();
                }
            }
                    //What happens when the negative button is pressed
        }).setNegativeButton("Cancel", new DialogInterface.OnClickListener(){
                public void onClick(DialogInterface d, int which) {
                d.dismiss();
            }
        }).create().show();