代码拉取完成,页面将自动刷新
同步操作将从 bits-chen/NextInput-Android 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
inputs
Inputs校验核心模块,实现校验库的整体架构;见: Inputs
android
Android 外壳模块,针对Android平台的组件访问做支持;Inputs校验核心模块,实现校验库的整体架构;
更详细文档,见: Inputs
final AndroidNextInputs inputs = new AndroidNextInputs();
final WidgetAccess access = new WidgetAccess(this);
// 一、流式API
inputs // 必选,手机号
.add(access.findEditText(R.id.form_field_1))
.with(StaticScheme.Required(), StaticScheme.ChineseMobile())
// 信用卡
.add(access.findEditText(R.id.form_field_2))
.with(StaticScheme.BankCard());
// 二、标准API
// 必选,数字,最大20字符
inputs.add(access.findEditText(R.id.form_field_3), StaticScheme.Required(), StaticScheme.Digits(), ValueScheme.MaxLength(20));
// 必选,邮件
inputs.add(access.findEditText(R.id.form_field_4), StaticScheme.Required(), StaticScheme.Email());
// 必选,与邮件相同
final LazyLoaders loader = new LazyLoaders(this);
inputs.add(access.findEditText(R.id.form_field_5), ValueScheme.Required(), ValueScheme.EqualsTo(loader.fromEditText(R.id.form_field_4)));
// Host
inputs.add(access.findEditText(R.id.form_field_6), StaticScheme.Host());
// URL
inputs.add(access.findEditText(R.id.form_field_6), StaticScheme.URL());
// MaxLength
inputs.add(access.findEditText(R.id.form_field_7), ValueScheme.MaxLength(5));
// MinLength
inputs.add(access.findEditText(R.id.form_field_8), ValueScheme.MinLength(4));
// RangeLength
inputs.add(access.findEditText(R.id.form_field_9), ValueScheme.RangeLength(4, 8));
// Not Blank
inputs.add(access.findEditText(R.id.form_field_10), StaticScheme.NotBlank());
// Numeric
inputs.add(access.findEditText(R.id.form_field_11), StaticScheme.Numeric());
// MaxValue
inputs.add(access.findEditText(R.id.form_field_12), ValueScheme.MaxValue(100));
// MinValue
inputs.add(access.findEditText(R.id.form_field_13), ValueScheme.MinValue(20));
// RangeValue
inputs.add(access.findEditText(R.id.form_field_14), ValueScheme.RangeValue(18, 30));
final Button submit = (Button) findViewById(R.id.form_commit);
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
boolean passed = inputs.test();
if (passed) {
submit.setText("校验通过");
}else{
submit.setText("校验失败");
access.findEditText(R.id.form_field_1).inputView.setText("12222");
access.findEditText(R.id.form_field_1).inputView.setError(null);
}
}
});
AndroidNextInputs
增加了Android支持,默认使用的AndroidMessageDisplay实现了Android内置组件的错误展示功能 :使用TextView.setError()和Toast来展示校验失败的消息。
WidgetAccess
是一个为Android创建的扩展工具类,用于读取输入组件的数据,通过它可以快捷地读取布局文件中的EditText等组件及其数据。
LazyLoaders
是一个为Android创建的扩展工具类,用于延迟加载组件数据,通过它可以快捷地添加基于Android输入组件的延迟加载器。
本项目的库文件托管在JCenter上,注意添加JCenter的仓库:
repositories {
jcenter()
}
dependencies {
compile 'com.github.yoojia:next-inputs-android:1.6'
}
关于本项目你有任何问题,可以加微信与我联系(抱歉,没有QQ群):
Copyright 2015-2016 Yoojia Chen
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。