gpt4 book ai didi

java - 如何禁止在编辑文本中输入零后的数字?

转载 作者:行者123 更新时间:2023-12-02 02:19:55 25 4
gpt4 key购买 nike

如何禁止在编辑文本中输入零后的数字?

我仅对此进行了验证..

 if (TextUtils.isEmpty(strBalance)) {
Toast.makeText(TransactionSellINActivity.this, "Amount should not be empty", Toast.LENGTH_SHORT)
.show();
} else if (strBalance.equalsIgnoreCase("0")) {
Toast.makeText(TransactionSellINActivity.this, "Amount should not be Zero", Toast.LENGTH_SHORT)
.show();
}

但是如果用户输入 01 或 001 或 02,03 等,?即零后的数字? -> 我想限制这些数字

遇到这种情况该如何处理?

最佳答案

if (TextUtils.isEmpty(strBalance)) {
Toast.makeText(TransactionSellINActivity.this, "Amount should not be empty", Toast.LENGTH_SHORT)
.show();
} else if (strBalance.equalsIgnoreCase("0")) {
Toast.makeText(TransactionSellINActivity.this, "Amount should not be Zero", Toast.LENGTH_SHORT)
.show();
}
else if(strBalance.indexOf("0")!=a.length()-1)
{
Toast.makeText(TransactionSellINActivity.this, "Amount Not Valid", Toast.LENGTH_SHORT)
.show();
}
else{
Toast.makeText(TransactionSellINActivity.this, "Amount Valid", Toast.LENGTH_SHORT)
.show();
}

关于java - 如何禁止在编辑文本中输入零后的数字?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48657972/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com