Android - Change components of a Dialog

0

I used a Dialog to display a custom alert like this:

Dialog dialog = new Dialog();
dialog.setContextView(R.layout.resource);
dialog.setTitle("Diálogo");
dialog.show();

But I can not change elements of the Dialog xml using this Activity.

    
asked by anonymous 14.06.2018 / 13:37

1 answer

0

First create an element in the Java class and then retrieve it from Dialog. For example:

public void dialogClick() {

   Dialog dialog = new Dialog();
   dialog.setContextView(R.layout.resource);
   dialog.setTitle("Diálogo");
   dialog.show();

   View = dialog.findViewById(R.id.sua_view);
   view.setOnClickListener(ASuaListener());

}
    
14.06.2018 / 15:35