es mein Freund folgen benutzerdefinierten Dialog dies Ihre benutzerdefinierten Schritte zur Kiste dailog
Schritt 1: -> ein Layout-Datei custom_layout in res/Layout-Ordner wie folgt
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> <TextView android:id="@+id/tv" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:padding="10dp" android:text="hello world" /> <Button android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:padding="10dp" android:text="hello world" /> <EditText android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:padding="10dp" android:text="hello world" /> <ImageView android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" android:src="@mipmap/ic_launcher" />
erstellen
Schritt ": -> 2 Erstellen Sie ein Dialg wie folgt in Ihrer Aktivität Java-Datei
Dialog custoDialog = new Dialog(MainActivity.this);
custoDialog.setContentView(R.layout.custom_layout);
Window window = custoDialog.getWindow();
window.setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT);
window.setGravity(Gravity.CENTER);
// acces you custom dialog controlss like this
TextView tv = (TextView) custoDialog.findViewById(R.id.tv);
tv.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//perfom actions here
}
});
custoDialog.show();
fragen Sie mich bei jeder Abfrage
danke! Das habe ich gesucht! – Noob
@Noob sehr willkommen, Kodierung zu genießen –