当前位置: 首页>>代码示例>>Java>>正文


Java TextWatcher类代码示例

本文整理汇总了Java中android.text.TextWatcher的典型用法代码示例。如果您正苦于以下问题:Java TextWatcher类的具体用法?Java TextWatcher怎么用?Java TextWatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TextWatcher类属于android.text包,在下文中一共展示了TextWatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: beautyEditText

import android.text.TextWatcher; //导入依赖的package包/类
protected void beautyEditText(final EditText mEditText, String hintStr, TextWatcher mTextWatcher) {
    mEditText.setHint(hintStr);
    mEditText.setHintTextColor(Color.parseColor("#1e0d0d0d"));
    mEditText.setTextColor(Color.parseColor("#0d0d0d"));
    SDKUtils.setBackground(mEditText, this.crMgmt.getDrawable("uac_input", true));
    mEditText.setTextSize(16.0f);
    if (mTextWatcher != null) {
        mEditText.addTextChangedListener(mTextWatcher);
    }
    mEditText.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            mEditText.setSelection(mEditText.length());
            mEditText.requestFocus();
            mEditText.setFocusable(true);
        }
    });
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:18,代码来源:BasicActivity.java

示例2: initListener

import android.text.TextWatcher; //导入依赖的package包/类
private void initListener() {
    findViewById(R.id.constraint_layout).setOnClickListener(this);
    fab.setOnClickListener(this);

    editText.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {
            needClearInput = false;
        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
            textInputLayout.setErrorEnabled(false);
        }

        @Override
        public void afterTextChanged(Editable editable) {
            editTextString = editText.getText().toString();
            if (editTextString.equals(""))
                setFabImage(false);
        }
    });
}
 
开发者ID:Omico,项目名称:WeiboPhotoLinktoPeople,代码行数:24,代码来源:MainActivity.java

示例3: removeTextChangedListener

import android.text.TextWatcher; //导入依赖的package包/类
@Override
public void removeTextChangedListener(TextWatcher watcher) {
    super.removeTextChangedListener(watcher);
    if (mCsDrawableViewManager != null){
        mCsDrawableViewManager.removeTextWatcher();
    }
}
 
开发者ID:matpag,项目名称:ClickDrawableTextView,代码行数:8,代码来源:ClickDrawableEditText.java

示例4: doNotAddTextWatcher_IfAlreadyAdded

import android.text.TextWatcher; //导入依赖的package包/类
@Test
public void doNotAddTextWatcher_IfAlreadyAdded() throws Exception {
    // Given
    given(view.getTag(anyInt()))
            .willReturn(mock(TextWatcher.class));

    BindingFunction function = TextChangedBindingFunction.create(listener);

    // When
    function.bind(view);

    // Then
    verify(view, never()).addTextChangedListener(any());
}
 
开发者ID:dmitry-zaitsev,项目名称:BlueTape,代码行数:15,代码来源:TextChangedBindingFunctionTest.java

示例5: removeTextWatcher

import android.text.TextWatcher; //导入依赖的package包/类
@Test
public void removeTextWatcher() throws Exception {
    // Given
    TextWatcher watcher = mock(TextWatcher.class);

    given(view.getTag(anyInt()))
            .willReturn(watcher);

    BindingFunction function = TextChangedBindingFunction.create(null);

    // When
    function.bind(view);

    // Then
    verify(view).removeTextChangedListener(watcher);
    verify(view).setTag(R.id.onTextChangedListener, null);
}
 
开发者ID:dmitry-zaitsev,项目名称:BlueTape,代码行数:18,代码来源:TextChangedBindingFunctionTest.java

示例6: buildForm

import android.text.TextWatcher; //导入依赖的package包/类
private void buildForm() {
    EditText formMessage = findViewById(R.id.form_input_message);
    AutoCompleteTextView formContact = findViewById(R.id.form_input_contact);
    TextWatcher watcherEmptiness = new EmptinessTextWatcher(this, formContact, formMessage);
    formContact.addTextChangedListener(watcherEmptiness);
    formMessage.addTextChangedListener(watcherEmptiness);

    new BuilderMessage().setView(formMessage).setSms(sms).build();
    new BuilderContact().setView(formContact).setSms(sms).setActivity(this).build();

    new BuilderSimCard().setActivity(this).setView(findViewById(R.id.form_sim_card)).setSms(sms).build();
    new BuilderRecurringMode()
        .setRecurringDayView((Spinner) findViewById(R.id.form_recurring_day))
        .setRecurringMonthView((Spinner) findViewById(R.id.form_recurring_month))
        .setDateView((DatePicker) findViewById(R.id.form_date))
        .setActivity(this)
        .setView(findViewById(R.id.form_recurring_mode))
        .setSms(sms)
        .build()
    ;

    new BuilderTime().setActivity(this).setView(findViewById(R.id.form_time)).setSms(sms).build();
    new BuilderDate().setActivity(this).setView(findViewById(R.id.form_date)).setSms(sms).build();

    new BuilderCancel().setView(findViewById(R.id.button_cancel)).setSms(sms).build();
}
 
开发者ID:yeriomin,项目名称:SmsScheduler,代码行数:27,代码来源:AddSmsActivity.java

示例7: createSelectStringDialogFilterTextWatcher

import android.text.TextWatcher; //导入依赖的package包/类
private static TextWatcher createSelectStringDialogFilterTextWatcher(final Activity activity
        , final List<Pair<Bitmap, String>> values
        , final double maxImageWidthInCM
        , final double maxImageHeightInCM
        , EditText filterText
        , final boolean matchCase
        , final boolean containsMode
        , final boolean multiSelect
        , final ListView list
        , final SortedSet<String> allSelectedItems
        , final ReturnableObject<FLUIAndroidIconLabelAndCheckListAdapter>
                                                                             currentCheckListAdapter) {
    return createSelectStringDialogFilterTextWatcher(activity
            , values
            , maxImageWidthInCM
            , maxImageHeightInCM
            , DEFAULT_TEXT_SIZE_IN_DIP
            , SizeUnit.DIP
            , filterText
            , matchCase
            , containsMode
            , multiSelect
            , list
            , allSelectedItems
            , currentCheckListAdapter);
}
 
开发者ID:pheyse,项目名称:fonotes,代码行数:27,代码来源:FLUIAndroidUtil.java

示例8: testInputEmail

import android.text.TextWatcher; //导入依赖的package包/类
@Test
public void testInputEmail() {
    SpannableStringBuilder builder = new SpannableStringBuilder();
    builder.append("abcdef");
    TextWatcher textWatcher = new CustomTextWatcher() {
        @Override
        public void afterTextChanged(Editable editable) {
            super.afterTextChanged(editable);
            loginRequest.setEmail(editable.toString());
        }
    };
    assertEquals("abcdef", builder.toString());
    textWatcher.afterTextChanged(builder);
    assertFalse(loginRequest.isEmailEmpty());
    assertFalse(loginRequest.isValidEmail());
    builder.clear();
    builder.append("[email protected]");
    textWatcher.afterTextChanged(builder);
    assertTrue(loginRequest.isValidEmail());
}
 
开发者ID:chungtruong,项目名称:AndroidDataBinding,代码行数:21,代码来源:LoginViewModelTest.java

示例9: testInputPassword

import android.text.TextWatcher; //导入依赖的package包/类
@Test
public void testInputPassword() {
    SpannableStringBuilder builder = new SpannableStringBuilder();
    builder.append("abcd");
    TextWatcher textWatcher = new CustomTextWatcher() {
        @Override
        public void afterTextChanged(Editable editable) {
            super.afterTextChanged(editable);
            loginRequest.setPassword(editable.toString());
        }
    };
    textWatcher.afterTextChanged(builder);
    assertFalse(loginRequest.isPasswordEmpty());
    assertFalse(loginRequest.isValidPassword());
    builder.clear();
    builder.append("abcd123");
    textWatcher.afterTextChanged(builder);
    assertTrue(loginRequest.isValidPassword());
}
 
开发者ID:chungtruong,项目名称:AndroidDataBinding,代码行数:20,代码来源:LoginViewModelTest.java

示例10: onFocusChange

import android.text.TextWatcher; //导入依赖的package包/类
@Override
public void onFocusChange(View v, boolean has_focus)
{
  EditText ed = (EditText)v;
  TextWatcher w = (TextWatcher)ed.getTag();
  ed.removeTextChangedListener(w);
  if(has_focus)
  {
    ed.setSelection(ed.getText().length());
    if(focus_listener != null)
    {
      focus_listener.FocusReceived(tag);
    }
  }
  ed.addTextChangedListener(w);
}
 
开发者ID:EXTER7,项目名称:IndustryCalculatorForEVE,代码行数:17,代码来源:BigDecimalEditText.java

示例11: setValue

import android.text.TextWatcher; //导入依赖的package包/类
public void setValue(BigDecimal value)
{
  TextWatcher w = (TextWatcher)editor.getTag();
  editor.removeTextChangedListener(w);
  if(value.compareTo(min) < 0)
  {
    value = min;
  }
  if(value.compareTo(max) > 0)
  {
    value = max;
  }
  DecimalFormat formatter = new DecimalFormat("###.##");
  editor.setText(formatter.format(value));
  editor.addTextChangedListener(w);   
}
 
开发者ID:EXTER7,项目名称:IndustryCalculatorForEVE,代码行数:17,代码来源:BigDecimalEditText.java

示例12: onFocusChange

import android.text.TextWatcher; //导入依赖的package包/类
@Override
public void onFocusChange(View v, boolean has_focus)
{
  EditText ed = (EditText)v;
  TextWatcher w = (TextWatcher)ed.getTag();
  ed.removeTextChangedListener(w);
  if(has_focus)
  {
    ed.setSelection(ed.getText().length());
  } else
  {
    int i = getValue(ed.getText().toString());
    ed.setText(String.valueOf(i));
  }
  ed.addTextChangedListener(w);
}
 
开发者ID:EXTER7,项目名称:IndustryCalculatorForEVE,代码行数:17,代码来源:IntegerEditText.java

示例13: onFocusChange

import android.text.TextWatcher; //导入依赖的package包/类
@Override
public void onFocusChange(View v, boolean has_focus)
{
  EditText ed = (EditText)v;
  TextWatcher w = (TextWatcher)ed.getTag();
  ed.removeTextChangedListener(w);
  if(has_focus)
  {
    ed.setSelection(ed.getText().length());
    if(focus_listener != null)
    {
      focus_listener.FocusReceived(tag);
    }
  }/* else
  {
    double i = get(ed.getText().toString());
    ed.setText(String.valueOf(i));
  }*/
  ed.addTextChangedListener(w);
}
 
开发者ID:EXTER7,项目名称:IndustryCalculatorForEVE,代码行数:21,代码来源:DoubleEditText.java

示例14: checkIsCorrectTextWatcher

import android.text.TextWatcher; //导入依赖的package包/类
protected boolean checkIsCorrectTextWatcher(Editable editable, TextWatcher textWatcher) {
    CARD_TYPE currentCardType = getCurrentCardType();
    CARD_TYPE newCardType = getNewCardType(editable.toString());

    if(newCardType == currentCardType) {
        return true;
    }

    if(newCardType == CARD_TYPE.OTHERS) {
        mEditText.removeTextChangedListener(textWatcher);
        mEditText.addTextChangedListener(new OtherCardTextWatcher(mEditText));
        mEditText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(OTHERS_MAX_LENGTH)});
        setCursorPosition();
    } else if(newCardType == CARD_TYPE.AMERICAN_EXPRESS) {
        mEditText.removeTextChangedListener(textWatcher);
        mEditText.addTextChangedListener(new AmericanExpressTextWatcher(mEditText));
        mEditText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(AMERICAN_EXPRESS_MAX_LENGTH)});
        setCursorPosition();
    }
    return false;
}
 
开发者ID:yekmer,项目名称:credit_card_lib,代码行数:22,代码来源:CreditCardBaseTextWatcher.java

示例15: searchableListAlert

import android.text.TextWatcher; //导入依赖的package包/类
public <T> AlertDialog.Builder searchableListAlert(final TextView text, final TextView title, final ArrayAdapter<T> adapter,
                                                   final ArrayList<T> list, final OnItemClickListener listener, TextWatcher textWatcher) {
  LayoutInflater factory = LayoutInflater.from(context);
  final LinearLayout alertView = (LinearLayout) factory.inflate(R.layout.alert_view_searchable_list, null);
  final EditText editText = (EditText) alertView.findViewById(R.id.edit_text);
  final ListView listView = (ListView) alertView.findViewById(R.id.list);
  listView.setOnItemClickListener(listener);
  listView.setAdapter(adapter);

  // Search text watcher.
  editText.addTextChangedListener(textWatcher);
  textWatcher.onTextChanged("", 0, 0, 0);

  return new AlertDialog.Builder(context)
          .setTitle(title.getText().toString())
          .setView(alertView)
          .setNegativeButton(R.string.cancel, null);
}
 
开发者ID:caseydavenport,项目名称:biermacht,代码行数:19,代码来源:AlertBuilder.java


注:本文中的android.text.TextWatcher类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。