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 inside the dialog box correctly, but need that after the user type the requested message that the dialog box close going back to the previous layout and providing new value to Edittext.
Thank you. I used an inflate because I wanted the dialog to have an editText, I solved the problem using a positivebutton "ok", it was what I needed to make it inflate and get the editText value. I don’t know why I couldn’t use Ismiss, it was a mistake. Thank you
– user116985
In Edt you need to put -> Edittext Edt = (Edittext) v1.findViewById( R.id.Edtm ); because edt is in the inflated view v1, otherwise it will give nullpointer
– AndersonCanteiro