From 0cbffe866b0e9ed071edc3295abb46454618da04 Mon Sep 17 00:00:00 2001 From: HapeLee <1321903405@qq.com> Date: Wed, 15 Oct 2025 00:19:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=95=B0=E5=80=BC=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=99=A8=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kazusa/ui/widget/number/NumberPickerDialog.kt | 12 ++++++------ app/src/main/res/layout/dialog_number_picker.xml | 9 +-------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/io/legato/kazusa/ui/widget/number/NumberPickerDialog.kt b/app/src/main/java/io/legato/kazusa/ui/widget/number/NumberPickerDialog.kt index f23897265..f72994adb 100644 --- a/app/src/main/java/io/legato/kazusa/ui/widget/number/NumberPickerDialog.kt +++ b/app/src/main/java/io/legato/kazusa/ui/widget/number/NumberPickerDialog.kt @@ -4,7 +4,6 @@ import android.app.AlertDialog import android.content.Context import android.view.View import android.widget.NumberPicker -import android.widget.TextView import com.google.android.material.button.MaterialButton import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.textfield.TextInputEditText @@ -17,7 +16,6 @@ class NumberPickerDialog(context: Context) { private var numberPicker: NumberPicker? = null private var editText: TextInputEditText? = null private var inputLayout: TextInputLayout? = null - private var tvRange: TextView? = null private var maxValue: Int? = null private var minValue: Int? = null private var value: Int? = null @@ -63,7 +61,6 @@ class NumberPickerDialog(context: Context) { numberPicker = dialog.findViewById(R.id.number_picker) inputLayout = dialog.findViewById(R.id.til_input) editText = dialog.findViewById(R.id.et_input) - tvRange = dialog.findViewById(R.id.tv_range) val btnSwitch = dialog.findViewById(R.id.btn_switch_input) numberPicker?.let { np -> @@ -71,20 +68,23 @@ class NumberPickerDialog(context: Context) { maxValue?.let { np.maxValue = it } value?.let { np.value = it } } - tvRange?.text = "输入范围: ${numberPicker?.minValue} - ${numberPicker?.maxValue}" btnSwitch?.setOnClickListener { useInputMode = !useInputMode if (useInputMode) { numberPicker?.visibility = View.GONE inputLayout?.visibility = View.VISIBLE - tvRange?.visibility = View.VISIBLE + + val min = minValue ?: numberPicker?.minValue + val max = maxValue ?: numberPicker?.maxValue + inputLayout?.hint = "输入范围: $min - $max" + editText?.setText(numberPicker?.value?.toString() ?: value?.toString()) } else { numberPicker?.visibility = View.VISIBLE inputLayout?.visibility = View.GONE - tvRange?.visibility = View.GONE inputLayout?.error = null + inputLayout?.hint = null } } diff --git a/app/src/main/res/layout/dialog_number_picker.xml b/app/src/main/res/layout/dialog_number_picker.xml index c27b2d56e..c950ae2ba 100644 --- a/app/src/main/res/layout/dialog_number_picker.xml +++ b/app/src/main/res/layout/dialog_number_picker.xml @@ -17,18 +17,11 @@ app:layout_constraintTop_toTopOf="parent" app:layout_constraintBottom_toBottomOf="parent"/> - -