I need to update a custom dialog content whenever that dialog is ready to be drawin. I am not sure this could be refreshed directly or if I need to close it first and re-ins
Get the view that the Dialog is using and [post]invalidate it.
Instead of Dialog.setContentView(int)
;
Do something like:
public class MyDialog {
View v = null;
public Dialog show(Context context) {
Dialog d = new Dialog(context);
v = LayoutInflater.from(context).inflate(R.layout.resource, null);
d.setContentView(v);
return d.show();
}
public void update() {
v.invalidate();
}
}
You can do everything in onPrepareDialog
. It is called every time a dialog is about to be shown.
void onPrepareDialog(final int id, final Dialog dialog) {
switch(id) {
case MY_DIALOG:
TextView txtView = (TextView)dialog.findViewById(R.id.mytext);
txtView.setText("My new text"):
....
}
}