close alertdialog open with inflate

0

I have a project with an open dialog box with an inflate giving the user the option to type a text to change the value of a String.

I'm having trouble closing this box and going back to the previous layout.

public class Calendario extends Activity {
    AlertDialog.Builder alert = new AlertDialog.Builder(Calendario.this);
    String Txt = "Digite sua mensagem";

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate( savedInstanceState );
    setContentView( R.layout.calendario );

Txtmessage = (TextView)  findViewById( R.id.EdtMensagemCalendar );
Txtmessage.setText( Txt );

Txtmessage.setOnClickListener( new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            View v1 = getLayoutInflater().inflate(R.layout.edit, null);
            alert.setView(v1);
            alert.create();
            Edt = (EditText)  findViewById( R.id.EdtM );
            alert.show();


        }

    } );

The project loads the edit layout into the dialog box correctly, but I need it after the user types the requested message to close the dialog box by returning to the previous layout and supplying a new value to EditText.

    
asked by anonymous 29.06.2018 / 17:29

1 answer

0

You can do the following: Open the dialog box, and when you click the OK button in the dialog box pick up the entered text, put it in that String and close the box.

Create a Listener for the dialog box and set it to the "OK" button.

This Listener can do this:

        String str = Edt.getText().toString(); //Pegar a String da caixa de diálogo
        alert.dismiss //fechar a caixa de diálogo
    
03.07.2018 / 09:20