在DialogActivity中設置標題和消息可以通過以下步驟實現:
<TextView
android:id="@+id/titleTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dialog Title"
android:textSize="20sp"
android:textColor="@android:color/black"/>
<TextView
android:id="@+id/messageTextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dialog Message"
android:textSize="16sp"
android:textColor="@android:color/black"/>
TextView titleTextView = findViewById(R.id.titleTextView);
titleTextView.setText("Custom Dialog Title");
TextView messageTextView = findViewById(R.id.messageTextView);
messageTextView.setText("Custom Dialog Message");
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Dialog Title");
builder.setMessage("Dialog Message");
AlertDialog dialog = builder.create();
dialog.show();
通過以上步驟,您可以在DialogActivity中設置標題和消息內容,并顯示一個自定義的對話框。