From 3ab91a74d150ade75f31ba38bdc823ccdc5b2d0b Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Mon, 7 Aug 2023 18:26:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=A4=BC=E7=89=A9=E6=A0=8F?= =?UTF-8?q?=E8=87=AA=E5=AE=9A=E4=B9=89=E6=95=B0=E9=87=8F=E8=BF=87=E9=95=BF?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E9=97=AA=E9=80=80=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/yunbao/common/views/GiftNumberPopup.java | 4 +++- .../java/com/yunbao/common/views/InputCustomPopup.java | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/common/src/main/java/com/yunbao/common/views/GiftNumberPopup.java b/common/src/main/java/com/yunbao/common/views/GiftNumberPopup.java index 4294b8b34..7a654aaba 100644 --- a/common/src/main/java/com/yunbao/common/views/GiftNumberPopup.java +++ b/common/src/main/java/com/yunbao/common/views/GiftNumberPopup.java @@ -54,7 +54,9 @@ public class GiftNumberPopup extends BottomPopupView { new XPopup.Builder(getContext()) .asCustom(new InputCustomPopup(getContext(), getContext().getString(R.string.the_title_financier3), - R.string.custom_quantity, true).setListener(new InputCustomPopup.InputCustomListener() { + R.string.custom_quantity, true) + .setMaxValue(4) + .setListener(new InputCustomPopup.InputCustomListener() { @Override public void onConfirm(String text) { if (!TextUtils.isEmpty(text)) { diff --git a/common/src/main/java/com/yunbao/common/views/InputCustomPopup.java b/common/src/main/java/com/yunbao/common/views/InputCustomPopup.java index b2598cd14..80b31e916 100644 --- a/common/src/main/java/com/yunbao/common/views/InputCustomPopup.java +++ b/common/src/main/java/com/yunbao/common/views/InputCustomPopup.java @@ -1,6 +1,7 @@ package com.yunbao.common.views; import android.content.Context; +import android.text.InputFilter; import android.text.InputType; import android.text.TextUtils; import android.view.View; @@ -22,6 +23,7 @@ public class InputCustomPopup extends CenterPopupView { private String message = ""; private int title = R.string.dialog_tip; private boolean isType; + private int maxValue=0; public InputCustomPopup(@NonNull Context context, String message, int title) { super(context); @@ -36,6 +38,11 @@ public class InputCustomPopup extends CenterPopupView { this.isType = isType; } + public InputCustomPopup setMaxValue(int maxValue) { + this.maxValue = maxValue; + return this; + } + public InputCustomPopup(@NonNull Context context, int title) { super(context); this.title = title; @@ -53,6 +60,9 @@ public class InputCustomPopup extends CenterPopupView { super.onCreate(); EditText content = findViewById(R.id.content); TextView titleText = findViewById(R.id.title); + if(maxValue>0){ + content.setFilters(new InputFilter[]{new InputFilter.LengthFilter(maxValue)}); + } if (isType) { content.setHint(message);