Ich versuche, einen Warndialog mit einem benutzerdefinierten Ansichtslayout zu erstellen, aber der Bildschirm wird nur gedimmt, ohne dass ein Dialogfeld angezeigt wird.AlertDialog mit benutzerdefiniertem Layout wird nicht angezeigt
AlertDialog.Builder builder = new AlertDialog.Builder(MyActivity.this);
builder.setView(findViewById(R.id.system_profile_dialog));
AlertDialog setSysProfileDialog = builder.create();
setSysProfileDialog.show();
XML:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/system_profile_dialog"
android:layout_width="match_parent"
android:layout_height="match_parent">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:hint="@string/system_profile_hint"
android:inputType="number" />
</LinearLayout>
Dieser Aufruf ist gut für API 21 und höher. –
Ja, Sie haben Recht. Wenn Sie <21 zielen, müssen Sie tun, was Vucko vorgeschlagen hat. – colens