У меня возникают некоторые трудности с обновлением содержимого AlertDialog
по методу onPrepareDialog
.
Я устанавливаю содержимое AlertDialog, но на экран выводится диалоговое окно без кнопок ибез фона.Вероятно, проблема связана с Builder
.
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_USER_INFORMATION:
AlertDialog.Builder builder = new AlertDialog.Builder(this);
return builder.create();
default:
return null;
}
}
@Override
protected void onPrepareDialog(final int id, final Dialog dialog) {
switch (id) {
case DIALOG_USER_INFORMATION:
createUserInformationAlertDialog(dialog);
break;
}
}
public void createUserInformationAlertDialog(Dialog dialogIn) {
AlertDialog alertDialog = (AlertDialog) dialogIn;
View dialoglayout = alertDialog.getLayoutInflater().inflate(
R.layout.dialog_user_info,
(ViewGroup) findViewById(R.id.dialog_user_layout_root));
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(dialoglayout);
EventAttendant ea = this.event.getCrowd().getAttendees()
.get(positionUserToHaveInformationDisplayedOnTheDialog);
final EventAttendant clone = (EventAttendant) ea.clone();
// Setting values
TextView textView = (TextView) dialoglayout.findViewById(R.id.user_name_value);
textView.setText(ea.getName());
builder.setPositiveButton(Locale_PT_BR.SEE_ON_FACEBOOK,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {/* User clicked OK so do some stuff */
}
});
builder.setNegativeButton(Locale_PT_BR.BACK,
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int whichButton) {...}
});
builder.setView(dialoglayout);
alertDialog.setView(dialoglayout);
alertDialog.setContentView(dialoglayout);
}