本文整理汇总了Java中android.support.design.widget.TextInputLayout.setError方法的典型用法代码示例。如果您正苦于以下问题:Java TextInputLayout.setError方法的具体用法?Java TextInputLayout.setError怎么用?Java TextInputLayout.setError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.design.widget.TextInputLayout
的用法示例。
在下文中一共展示了TextInputLayout.setError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkEmail
import android.support.design.widget.TextInputLayout; //导入方法依赖的package包/类
private boolean checkEmail(EditText emailEditText, TextInputLayout emailInputLayout) {
if (emailEditText.getText().toString().trim().isEmpty()) {
emailInputLayout.setErrorEnabled(true);
emailInputLayout.setError(getString(R.string.error_no_email));
if (emailEditText.requestFocus()) {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
return false;
} else {
if (android.util.Patterns.EMAIL_ADDRESS.matcher(emailEditText.getText().toString()).matches()) {
emailInputLayout.setErrorEnabled(false);
} else {
emailInputLayout.setErrorEnabled(true);
emailInputLayout.setError(getString(R.string.error_no_email));
if (emailEditText.requestFocus()) {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
return false;
}
}
return true;
}
示例2: onClick
import android.support.design.widget.TextInputLayout; //导入方法依赖的package包/类
@Override
public void onClick(View v) {
TextInputLayout tilUsername = (TextInputLayout) findViewById(R.id.TILUsername);
TextInputLayout tilPassword = (TextInputLayout) findViewById(R.id.TILPassword);
final String strUsername = etUsername.getText().toString();
final String strPassword = etPassword.getText().toString();
if (v.equals(btnLogin)){
if (strUsername.equals("")){
tilUsername.setError("Kullanıcı adı boş olamaz.");
}else if (strPassword.equals("")){
tilPassword.setError("Parola adı boş olamaz.");
}else{
Request request = new Request(this, url, com.android.volley.Request.Method.POST);
request.requestVolleyAuth(this, strUsername, strPassword);
progressDialog = new ProgressDialog(this);
progressDialog.setMessage("Giriş Yapılıyor..");
progressDialog.show();
}
}
}
示例3: isInputEditTextMatches
import android.support.design.widget.TextInputLayout; //导入方法依赖的package包/类
public boolean isInputEditTextMatches(TextInputEditText textInputEditText1, TextInputEditText textInputEditText2, TextInputLayout textInputLayout, String message) {
String value1 = textInputEditText1.getText().toString().trim();
String value2 = textInputEditText2.getText().toString().trim();
if (!value1.contentEquals(value2)) {
textInputLayout.setError(message);
hideKeyboardFrom(textInputEditText2);
return false;
} else {
textInputLayout.setErrorEnabled(false);
}
return true;
}
示例4: checkDocument
import android.support.design.widget.TextInputLayout; //导入方法依赖的package包/类
private boolean checkDocument(EditText editText, TextInputLayout textInputLayout) {
if (editText.getText().toString().trim().isEmpty()) {
textInputLayout.setErrorEnabled(true);
textInputLayout.setError(getString(R.string.error_no_dni));
if (editText.requestFocus()) {
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}
return false;
} else {
textInputLayout.setErrorEnabled(false);
}
return true;
}
示例5: validateAccount
import android.support.design.widget.TextInputLayout; //导入方法依赖的package包/类
private boolean validateAccount() {
TextInputLayout accountInputLayout = (TextInputLayout) fragmentView.findViewById(R.id.account_input_layout);
EditText accountEditText = (EditText) fragmentView
.findViewById(R.id.account_edittext);
String accountText = accountEditText.getText().toString();
if (TextUtils.isEmpty(accountText)) {
accountInputLayout.setError(getString(R.string.account_empty_error_message));
requestFocus(accountEditText);
return false;
} else {
accountInputLayout.setErrorEnabled(false);
}
return true;
}
示例6: titleButtonListener
import android.support.design.widget.TextInputLayout; //导入方法依赖的package包/类
public void titleButtonListener(View v) {
EditText title = (EditText) findViewById(R.id.title_input);
TextInputLayout titleLayout = (TextInputLayout) findViewById(R.id.title_input_layout);
if (title.getText().length() == 0) {
titleLayout.setError(getString(R.string.must_insert_issue_title));
} else {
title.setError(null);
mTitle = title.getText().toString();
nextPage();
}
}
示例7: textInputErrorTwinkle
import android.support.design.widget.TextInputLayout; //导入方法依赖的package包/类
public static void textInputErrorTwinkle(TextInputLayout il, String str) {
String error = (String) il.getError();
if (TextUtils.isEmpty(error)) {
error = TextUtils.isEmpty(str) ? "!" : str;
}
il.setErrorEnabled(false);
il.setError(error);
il.setErrorEnabled(true);
}
示例8: setError
import android.support.design.widget.TextInputLayout; //导入方法依赖的package包/类
public static void setError(TextInputLayout til, @Nullable String error,
boolean set) {
if (set) {
if (til.getError() == null) til.setError(error);
} else {
til.setError(null);
}
}
示例9: validatePassword
import android.support.design.widget.TextInputLayout; //导入方法依赖的package包/类
private boolean validatePassword() {
TextInputLayout passwordInputLayout = (TextInputLayout) fragmentView.findViewById(R.id.password_input_layout);
EditText passwordEditText = (EditText) fragmentView
.findViewById(R.id.password_edittext);
String passwordText = passwordEditText.getText().toString();
if (TextUtils.isEmpty(passwordText)) {
passwordInputLayout.setError(getString(R.string.password_empty_error_message));
requestFocus(passwordEditText);
return false;
} else {
passwordInputLayout.setErrorEnabled(false);
}
return true;
}
示例10: isInputEditTextFilled
import android.support.design.widget.TextInputLayout; //导入方法依赖的package包/类
/**
* method to check InputEditText filled .
*
* @param textInputEditText
* @param textInputLayout
* @param message
* @return
*/
public boolean isInputEditTextFilled(TextInputEditText textInputEditText, TextInputLayout textInputLayout, String message) {
String value = textInputEditText.getText().toString().trim();
if (value.isEmpty()) {
textInputLayout.setError(message);
hideKeyboardFrom(textInputEditText);
return false;
} else {
textInputLayout.setErrorEnabled(false);
}
return true;
}
示例11: setError
import android.support.design.widget.TextInputLayout; //导入方法依赖的package包/类
public static void setError(TextView textView, String errorMessage) {
TextInputLayout textInputLayout = getTextInputLayout(textView);
if (textInputLayout != null) {
textInputLayout.setErrorEnabled(!TextUtils.isEmpty(errorMessage));
textInputLayout.setError(errorMessage);
} else {
textView.setError(errorMessage);
}
}
示例12: doRenameBook
import android.support.design.widget.TextInputLayout; //导入方法依赖的package包/类
private void doRenameBook(Book book, String name, TextInputLayout inputLayout) {
if (!TextUtils.isEmpty(name)) {
inputLayout.setError(null);
mSyncFragment.renameBook(book, name);
} else {
inputLayout.setError(getString(R.string.can_not_be_empty));
}
}
示例13: validateInputs
import android.support.design.widget.TextInputLayout; //导入方法依赖的package包/类
private boolean validateInputs() {
boolean valid = true;
// Validates title (required field, ensure title is given.)
TextInputLayout titleWrapper = getView().findViewById(R.id.edit_title_wrapper);
TextInputEditText title = getView().findViewById(R.id.edit_title);
if (title.getText().toString().isEmpty()) {
titleWrapper.setErrorEnabled(true);
titleWrapper.setError("This field is required.");
title.requestFocus();
myActivity.hideSoftKeyboard(false);
valid = false;
} else {
titleWrapper.setError(null);
titleWrapper.setErrorEnabled(false);
}
// Validates due_date (must be later than now.)
TextInputLayout timeWrapper = getView().findViewById(R.id.edit_time_wrapper);
TextInputEditText time = getView().findViewById(R.id.edit_time);
long date_time = myCalendar.getTimeInMillis();
long current_date_time = System.currentTimeMillis();
if (date_time < current_date_time){
timeWrapper.setErrorEnabled(true);
timeWrapper.setError("Please select a time later than now");
time.requestFocus();
valid = false;
} else {
time.setError(null);
timeWrapper.setErrorEnabled(false);
}
return valid;
}
示例14: setErrorStyle
import android.support.design.widget.TextInputLayout; //导入方法依赖的package包/类
private void setErrorStyle(EditText editText, TextInputLayout textInputLayout, int idMessage) {
textInputLayout.setErrorEnabled(true);
textInputLayout.setError(getString(idMessage));
requestFocus(editText);
}
示例15: setErrorText
import android.support.design.widget.TextInputLayout; //导入方法依赖的package包/类
/**
* Facilitates binding error text to a TextInputLayout.
*/
@BindingAdapter("errorText")
public static void setErrorText(TextInputLayout layout, String errorText) {
layout.setError(errorText);
}