TextInputLayout 登录的实现
来源:互联网 发布:我的世界ipad版枪械js 编辑:程序博客网 时间:2024/05/18 15:08
TextInputLayout
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="65dp"
android:orientation="vertical">
<android.support.design.widget.TextInputLayout
android:id="@+id/layout_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:counterEnabled="false"
app:counterMaxLength="5"
>
<EditText
android:id="@+id/input_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入账号"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/layout_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:counterEnabled="false"
app:counterMaxLength="11"
>
<EditText
android:id="@+id/input_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="请输入入密码"
android:inputType="textPassword"
android:singleLine="true" />
</android.support.design.widget.TextInputLayout>
<Button
android:id="@+id/login"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:background="@color/colorPrimary"
android:text="commit"
android:textColor="#ffffff"
android:textSize="20sp"
android:textStyle="bold" />
</LinearLayout>
代码
private TextInputEditText ut;
private EditText et;
private EditText input_name;
private EditText input_password;
private EditText input_email;
private TextInputLayout layout_name;
private TextInputLayout layout_password;
private TextInputLayout layout_email;
private Button btn_login;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initWidget();
}
private void initWidget() {
input_name = (EditText) findViewById(R.id.input_name);
input_password = (EditText) findViewById(R.id.input_password);
layout_name = (TextInputLayout) findViewById(R.id.layout_name);
layout_password = (TextInputLayout) findViewById(R.id.layout_password);
btn_login = (Button) findViewById(R.id.login);
btn_login.setOnClickListener(this);
}
@Override
public void onClick(View v) {
if (input_name.getText().toString().trim().equals("aaa")) {
layout_name.setErrorEnabled(false);
}else{
layout_name.setError("您输入的账号不对");
layout_password.setErrorEnabled(true);
//requestFocus谁不对让谁获取焦点
input_name.requestFocus();
}
if (input_password.getText().toString().trim().equals("aaa")) {
layout_password.setErrorEnabled(false);
}else{
layout_password.setErrorEnabled(true);
layout_password.setError("您输入的密码不对");
input_password.requestFocus();
}
}
1 0
- TextInputLayout 登录的实现
- TextInputLayout实现登录注册动画效果
- Android客户端之“微服私访”App的系统学习(二)TextInputLayout实现登录界面和LitePal初始化本地数据库
- 快速开发android应用2-使用TextInputLayout实现用户登录及验证
- TextInputLayout 的简单使用
- TextInputLayout的使用
- TextInputLayout的使用
- TextInputLayout的使用
- TextInputLayout的学习
- TextInputLayout 的使用
- TextInputLayout的使用
- android TextInputLayout的使用
- TextInputLayout&TextInputEditText的使用
- TextInputLayout的简单使用
- TextInputLayout的使用
- TextInputLayout的使用
- TextInputLayout的使用
- TextInputLayout的使用
- Mac OS 安装 Scrapy一直失败的解决方案
- Java语言基础-13.Java系统API方法调用
- .NET 中ajax如何调用后台.cs文件中的方法
- Linux下Redis启动/关闭/重启服务脚本
- PHP文件下载
- TextInputLayout 登录的实现
- Xcode8 - apploader 上传失败 - ERROR ITMS-90168: "The binary you uploaded was invalid."
- linux常用查看硬件设备信息命令
- 抓住2016年的最后时光,做个总结
- 详解Java中的clone方法 -- 原型模式
- WARN React-native@0.35.0 requires a peer of react@~15.3.1 but none was installed.
- iOS学习资源收集
- list
- APNS 学习总结(五)