在DialogActivity中設(shè)置標(biāo)題和消息可以通過以下步驟實(shí)現(xiàn):
<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中設(shè)置標(biāo)題和消息內(nèi)容,并顯示一個(gè)自定義的對話框。