0

我有一个 Bottomsheetdialog,不会更改为暗模式,也不会更改语言。难道我做错了什么?onclick 监听器正在工作。科特林代码:

private fun outsideDoorModalShow() {
        val bottomSheetDialog = BottomSheetDialog(activity, R.style.BottomSheetDialogTheme)
        val bottomSheetView = LayoutInflater.from(activity.applicationContext).inflate(
                R.layout.outside_door_bottom_modal
                , null
        )

        bottomSheetDialog.behavior.state = BottomSheetBehavior.STATE_EXPANDED
        bottomSheetView.findViewById<Button>(R.id.order_outside_door_button_order).setOnClickListener { orderOutsideDoor(bottomSheetDialog) }
        bottomSheetDialog.setContentView(bottomSheetView)
        bottomSheetDialog.show()
    }

xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:id="@+id/outside_door_modal_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@drawable/bottom_sheet_background"
    android:orientation="vertical">


/.../


    <Button
        android:id="@+id/order_outside_door_button_order"
        style="@style/OnboardingButtonAppearance"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginStart="16dp"
        android:layout_marginTop="16dp"
        android:layout_marginEnd="16dp"
        android:layout_marginBottom="32dp"
        android:text="@string/order" />

</LinearLayout>

4

1 回答 1

0

弄清楚了。不得不更换

val bottomSheetView = LayoutInflater.from(activity.applicationContext).inflate(
                R.layout.outside_door_bottom_modal
                , null
        )

val bottomSheetView = LayoutInflater.from(activity).inflate(
                R.layout.outside_door_bottom_modal
                , null
        )

```
于 2020-10-27T07:54:49.240 回答