Ich versuche, meinem AlertDialog Builder einen Titel hinzuzufügen. Wenn ich das Thema hinzufüge, wird mein Titel in den Auswahlbereich verschoben.
Hier ist das erste Beispiel:Das Anwenden eines Designs auf AlertDialog Builder führt dazu, dass der Titel nicht korrekt funktioniert
classificationButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(
new ContextThemeWrapper(mContext, android.R.style.Theme_Holo_Dialog));
//building my selection options
builder.setItems(classificationList, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
String desiredClassification = classificationList[which];
if (!getClassification().equals(desiredClassification)) {
CallsignContract.updateClassification(desiredClassification, mContext);
setClassification(desiredClassification);
classificationButton.setText(desiredClassification);
}
}
});
builder.setTitle(R.string.classification_alert_header)
.create().show();
}
});
Dies ist das Ergebnis.
Bei diesem zweiten Versuch erstelle ich einen Alertdialog vom Builder und gebe diesem einen Titel. Das Ergebnis ist der korrekte Titel, aber der Titel erscheint wieder im Auswahlbereich.
classificationButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(
new ContextThemeWrapper(mContext, android.R.style.Theme_Holo_Dialog));
//building my selection options
builder.setItems(classificationList, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
String desiredClassification = classificationList[which];
if (!getClassification().equals(desiredClassification)) {
CallsignContract.updateClassification(desiredClassification, mContext);
setClassification(desiredClassification);
classificationButton.setText(desiredClassification);
}
}
});
AlertDialog alertDialog = builder.create();
alertDialog.setTitle(R.string.classification_alert_header);
alertDialog.show();
}
});
Vielen Dank!
Ist Ihr Titel nicht in 'classificationList' Array? –
@UilqueMessias Nein. Das Array classificationList enthält nur Nicht spezifiziert, Nicht klassifiziert, Vertraulich und Geheimnis. – RYDiiN