本文整理匯總了Java中android.support.design.widget.TextInputEditText.requestFocus方法的典型用法代碼示例。如果您正苦於以下問題:Java TextInputEditText.requestFocus方法的具體用法?Java TextInputEditText.requestFocus怎麽用?Java TextInputEditText.requestFocus使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.design.widget.TextInputEditText
的用法示例。
在下文中一共展示了TextInputEditText.requestFocus方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_login);
// Set up the login form.
mServerView = (TextInputEditText) findViewById(R.id.server);
mUsernameView = (TextInputEditText) findViewById(R.id.user);
mPasswordView = (TextInputEditText) findViewById(R.id.password);
mSignInButton = (Button) findViewById(R.id.user_sign_in_button);
mLoginFormView = findViewById(R.id.login_form);
mProgressView = findViewById(R.id.login_progress);
addListenerOnButton();
mUsernameView.requestFocus();
}
示例2: validateInputs
import android.support.design.widget.TextInputEditText; //導入方法依賴的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;
}
示例3: defineObjects
import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
private void defineObjects() {
message = (TextInputEditText) findViewById(R.id.post_call_text);
Switch emergency = (Switch) findViewById(R.id.post_call_emergencyswitch);
String m = user.toUpperCase();
m += ": ";
message.setText(m);
message.requestFocus();
emergency.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
emergencyBool = isChecked;
}
});
}
示例4: setFieldError
import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
protected void setFieldError(TextInputEditText field, String message) {
BaseAuthViewState vs = (BaseAuthViewState<RegistrationView>) viewState;
vs.setShowForm();
setFormEnabled(true);
field.setError(message);
field.requestFocus();
textViewFailure.setVisibility(View.GONE);
signUpProgressBar.setVisibility(View.GONE);
}
示例5: setFieldError
import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
@Override
protected void setFieldError(TextInputEditText field, String message) {
BaseAuthViewState vs = (BaseAuthViewState<LoginView>) viewState;
vs.setShowForm();
setFormEnabled(true);
field.setError(message);
field.requestFocus();
authErrorView.setVisibility(View.GONE);
loginProgressBar.setVisibility(View.GONE);
}
示例6: hasText
import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
public static boolean hasText(Context context, TextInputEditText editText) {
String text = editText.getText().toString().trim();
if (text.isEmpty()) {
editText.requestFocus();
editText.setError(context.getString(R.string.edittext_error));
}
return !text.isEmpty();
}
示例7: setFocused
import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
@BindingAdapter("focused")
public static void setFocused(TextInputEditText editText, boolean requestFocus) {
if (requestFocus)
editText.requestFocus();
}