本文整理匯總了Java中android.support.design.widget.TextInputEditText.addTextChangedListener方法的典型用法代碼示例。如果您正苦於以下問題:Java TextInputEditText.addTextChangedListener方法的具體用法?Java TextInputEditText.addTextChangedListener怎麽用?Java TextInputEditText.addTextChangedListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.support.design.widget.TextInputEditText
的用法示例。
在下文中一共展示了TextInputEditText.addTextChangedListener方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: onCreate
import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_router);
coordinatorLayout = (CoordinatorLayout) findViewById(R.id.layout_coordinator);
snackbarColor = ResourcesCompat.getColor(getResources(), R.color.colorPrimaryDark, null);
gatewayEditText = (TextInputEditText) findViewById(R.id.input_gateway);
gatewayEditText.addTextChangedListener(this);
usernameEditText = (TextInputEditText) findViewById(R.id.input_username);
usernameEditText.addTextChangedListener(this);
passwordEditText = (TextInputEditText) findViewById(R.id.input_password);
passwordEditText.addTextChangedListener(this);
routerPresenter = new RouterPresenter(this);
routerPresenter.setupFields();
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(this);
}
示例2: onViewCreated
import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if(view!=null){
caption.setText(getString(R.string.log_in_label));
view.setBackgroundColor(ContextCompat.getColor(getContext(),R.color.color_log_in));
for(TextInputEditText editText:views){
if(editText.getId()==R.id.password_input_edit){
final TextInputLayout inputLayout=ButterKnife.findById(view,R.id.password_input);
Typeface boldTypeface = Typeface.defaultFromStyle(Typeface.BOLD);
inputLayout.setTypeface(boldTypeface);
editText.addTextChangedListener(new TextWatcherAdapter(){
@Override
public void afterTextChanged(Editable editable) {
inputLayout.setPasswordVisibilityToggleEnabled(editable.length()>0);
}
});
}
editText.setOnFocusChangeListener((temp,hasFocus)->{
if(!hasFocus){
boolean isEnabled=editText.getText().length()>0;
editText.setSelected(isEnabled);
}
});
}
}
}
示例3: onViewCreated
import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if(view!=null){
view.setBackgroundColor(ContextCompat.getColor(getContext(),R.color.color_sign_up));
caption.setText(getString(R.string.sign_up_label));
for(TextInputEditText editText:views){
if(editText.getId()==R.id.password_input_edit){
final TextInputLayout inputLayout= ButterKnife.findById(view,R.id.password_input);
final TextInputLayout confirmLayout=ButterKnife.findById(view,R.id.confirm_password);
Typeface boldTypeface = Typeface.defaultFromStyle(Typeface.BOLD);
inputLayout.setTypeface(boldTypeface);
confirmLayout.setTypeface(boldTypeface);
editText.addTextChangedListener(new TextWatcherAdapter(){
@Override
public void afterTextChanged(Editable editable) {
inputLayout.setPasswordVisibilityToggleEnabled(editable.length()>0);
}
});
}
editText.setOnFocusChangeListener((temp,hasFocus)->{
if(!hasFocus){
boolean isEnabled=editText.getText().length()>0;
editText.setSelected(isEnabled);
}
});
}
caption.setVerticalText(true);
foldStuff();
caption.setTranslationX(getTextPadding());
}
}
示例4: setCreateAccountView
import android.support.design.widget.TextInputEditText; //導入方法依賴的package包/類
/**
* 配置“錄入賬號”視圖
*/
private void setCreateAccountView() {
// 賬號輸入布局
final TextInputLayout accountLayout = mCreateAccountView.findViewById(R.id.accountEditLayout);
// 密碼輸入布局
final TextInputLayout pwdLayout = mCreateAccountView.findViewById(R.id.pwdEditLayout);
// 賬號輸入框
final TextInputEditText accountEditText = mCreateAccountView.findViewById(R.id.accountEditText);
// 密碼輸入框
final TextInputEditText pwdEditText = mCreateAccountView.findViewById(R.id.pwdEditText);
// 賬號錯誤提示
final String accountError = getString(R.string.accountError);
// 密碼錯誤提示
final String pwdError = getString(R.string.pwdError);
/// 綁定文本監聽器
TextWatcher accountWatcher = new EditTextWatcher(accountLayout, accountError);
accountEditText.addTextChangedListener(accountWatcher);
TextWatcher pwdWatcher = new EditTextWatcher(pwdLayout, pwdError);
pwdEditText.addTextChangedListener(pwdWatcher);
/// 為“完成”按鈕綁定點擊監聽器
Button doneBut = mCreateAccountView.findViewById(R.id.doneBut);
doneBut.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
boolean accountOk = true;
boolean pwdOk = true;
/// 檢測賬號和密碼是否合格
if (accountEditText.length() == 0) {
accountLayout.setError(accountError);
accountOk = false;
}
if (mPwdType == TYPE_STATIC && pwdEditText.length() == 0) {
pwdLayout.setError(pwdError);
pwdOk = false;
}
/// 保存賬號和密碼
if (accountOk && pwdOk) {
String account = accountEditText.getText().toString();
switch (mPwdType) {
case TYPE_DYN:
// TODO 僅保存賬號
break;
case TYPE_STATIC:
String pwd = pwdEditText.getText().toString();
// TODO 保存賬號和密碼
break;
}
// 返回主頁麵
Intent intent = new Intent();
intent.putExtra(EXTRA_CREATE_NEW_ACCOUNT, true);
setResult(RESULT_OK, intent);
finish();
}
}
});
}