Java Code Examples for android.text.TextWatcher

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project agit, under directory /agit/src/main/java/com/madgag/agit/.

Source file: CloneLauncherActivity.java

  18 
vote

/** 
 * Called when the activity is first created.
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  fixImageTilingOn(getSupportActionBar());
  setContentView(R.layout.clone_launcher);
  ActionBar actionBar=getSupportActionBar();
  actionBar.setDisplayHomeAsUpEnabled(true);
  actionBar.setTitle(clone_launcher_activity_title);
  button.setOnClickListener(goCloneButtonListener);
  OnCheckedChangeListener checkBoxChangeListener=new OnCheckedChangeListener(){
    public void onCheckedChanged(    CompoundButton buttonView,    boolean isChecked){
      updateUIWithValidation();
    }
  }
;
  useDefaultGitDirLocationButton.setOnCheckedChangeListener(checkBoxChangeListener);
  bareRepoCheckbox.setOnCheckedChangeListener(checkBoxChangeListener);
  TextWatcher watcher=new TextWatcher(){
    public void onTextChanged(    CharSequence text,    int arg1,    int arg2,    int arg3){
    }
    public void beforeTextChanged(    CharSequence text,    int arg1,    int arg2,    int arg3){
    }
    public void afterTextChanged(    Editable gitDirEditText){
      updateUIWithValidation();
    }
  }
;
  cloneUrlEditText.addTextChangedListener(watcher);
  gitDirEditText.addTextChangedListener(watcher);
}
 

Example 2

From project k-9, under directory /src/com/fsck/k9/activity/setup/.

Source file: AccountSetupNames.java

  18 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.account_setup_names);
  mDescription=(EditText)findViewById(R.id.account_description);
  mName=(EditText)findViewById(R.id.account_name);
  mDoneButton=(Button)findViewById(R.id.done);
  mDoneButton.setOnClickListener(this);
  TextWatcher validationTextWatcher=new TextWatcher(){
    public void afterTextChanged(    Editable s){
      validateFields();
    }
    public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
    }
  }
;
  mName.addTextChangedListener(validationTextWatcher);
  mName.setKeyListener(TextKeyListener.getInstance(false,Capitalize.WORDS));
  String accountUuid=getIntent().getStringExtra(EXTRA_ACCOUNT);
  mAccount=Preferences.getPreferences(this).getAccount(accountUuid);
  if (mAccount.getName() != null) {
    mName.setText(mAccount.getName());
  }
  if (!Utility.requiredFieldValid(mName)) {
    mDoneButton.setEnabled(false);
  }
}
 

Example 3

From project android-rackspacecloud, under directory /src/com/rackspacecloud/android/.

Source file: AddLoadBalancerActivity.java

  17 
vote

private void setupText(){
  portEditText=(EditText)findViewById(R.id.edit_port_text);
  portEditText.addTextChangedListener(new TextWatcher(){
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      selectedPort=s.toString();
      updateVipIndicatorLight();
    }
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void afterTextChanged(    Editable s){
    }
  }
);
}
 

Example 4

From project android-voip-service, under directory /src/main/java/org/linphone/.

Source file: AbstractContactPickerActivity.java

  17 
vote

protected void createCustomPicker(){
  mContactList=(ListView)findViewById(R.id.contactList);
  mcontactFilter=(EditText)findViewById(R.id.contactFilter);
  mcontactFilter.addTextChangedListener(new TextWatcher(){
    public void onTextChanged(    CharSequence s,    int start,    int b,    int c){
    }
    public void beforeTextChanged(    CharSequence s,    int st,    int c,    int a){
    }
    public void afterTextChanged(    Editable s){
      adapter.runQueryOnBackgroundThread(s);
      adapter.getFilter().filter(s.toString());
    }
  }
);
  String[] from=new String[]{col_display_name};
  int[] to=new int[]{android.R.id.text1};
  int layout=android.R.layout.simple_list_item_1;
  adapter=new SimpleCursorAdapter(this,layout,runQuery(null),from,to);
  adapter.setFilterQueryProvider(this);
  mContactList.setAdapter(adapter);
  mContactList.setOnItemClickListener(new OnItemClickListener(){
    public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      final CharSequence contactName=((TextView)view.findViewById(android.R.id.text1)).getText();
      choosePhoneNumberAndDial(contactName,String.valueOf(id));
    }
  }
);
}
 

Example 5

From project Book-Catalogue, under directory /src/com/eleybourn/bookcatalogue/properties/.

Source file: StringProperty.java

  17 
vote

/** 
 * Build the editor for this property
 */
@Override public View getView(LayoutInflater inflater){
  View v=inflater.inflate(R.layout.property_value_string,null);
  ViewTagger.setTag(v,R.id.TAG_PROPERTY,this);
  final TextView name=(TextView)v.findViewById(R.id.name);
  final EditText value=(EditText)v.findViewById(R.id.value);
  name.setText(getName());
  value.setHint(getName());
  value.setText(get());
  value.addTextChangedListener(new TextWatcher(){
    @Override public void afterTextChanged(    Editable s){
      set(s.toString());
    }
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
    }
  }
);
  return v;
}
 

Example 6

From project RoboBinding, under directory /robobinding/src/main/java/org/robobinding/viewattribute/edittext/.

Source file: OnTextChangedAttribute.java

  17 
vote

@Override protected void bind(final Command command){
  view.addTextChangedListener(new TextWatcher(){
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      TextChangedEvent event=new TextChangedEvent(view,start,before,count);
      command.invoke(event);
    }
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void afterTextChanged(    Editable s){
    }
  }
);
}
 

Example 7

From project SORMA, under directory /sorma/examples/sorma-address-book/src/com/gaoshin/sorma/addressbook/.

Source file: PhoneView.java

  17 
vote

private void setupPhoneNumberView(){
  phoneNumberView=new EditText(getContext());
  addView(phoneNumberView);
  phoneNumberView.addTextChangedListener(new TextWatcher(){
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
    }
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void afterTextChanged(    Editable s){
      phone.setNumber(phoneNumberView.getText().toString());
    }
  }
);
}
 

Example 8

From project Alerte-voirie-android, under directory /src/com/fabernovel/alertevoirie/.

Source file: AddCommentActivity.java

  16 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  requestWindowFeature(Window.FEATURE_LEFT_ICON);
  setContentView(R.layout.layout_add_comment);
  getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,R.drawable.icon_nouveau_rapport);
  final EditText commentField=(EditText)findViewById(R.id.EditText_comment);
  commentField.setText(getIntent().getStringExtra(IntentData.EXTRA_COMMENT));
  ((TextView)findViewById(R.id.TextView_remaining_chars)).setText((140 - commentField.getText().length()) + " car. restant");
  commentField.addTextChangedListener(new TextWatcher(){
    public void afterTextChanged(    Editable s){
      ((TextView)findViewById(R.id.TextView_remaining_chars)).setText((140 - commentField.getText().length()) + " car. restant");
    }
    public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
    }
  }
);
  findViewById(R.id.Button_validate).setOnClickListener(new OnClickListener(){
    @Override public void onClick(    View v){
      if (commentField.getText().toString().trim().length() > 0) {
        Intent result=new Intent();
        result.putExtra(IntentData.EXTRA_COMMENT,commentField.getText().toString());
        setResult(RESULT_OK,result);
        finish();
      }
 else {
        Toast.makeText(getApplicationContext(),"Veuillez entrer un commentaire",Toast.LENGTH_SHORT).show();
      }
    }
  }
);
}
 

Example 9

From project and-bible, under directory /AndBible/src/net/bible/android/view/activity/navigation/.

Source file: ChooseDictionaryWord.java

  16 
vote

/** 
 * Called when the activity is first created. 
 */
@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.choose_dictionary_page);
  if (CurrentPageManager.getInstance().getCurrentDictionary().getCurrentDocument() == null) {
    Log.e(TAG,"No Dictionary");
    finish();
    return;
  }
  initialise();
  EditText searcheditText=(EditText)findViewById(R.id.searchText);
  searcheditText.addTextChangedListener(new TextWatcher(){
    @Override public void onTextChanged(    CharSequence searchText,    int arg1,    int arg2,    int arg3){
      showPossibleDictionaryKeys(searchText.toString());
    }
    @Override public void afterTextChanged(    Editable searchText){
    }
    @Override public void beforeTextChanged(    CharSequence arg0,    int arg1,    int arg2,    int arg3){
    }
  }
);
  searcheditText.requestFocus();
}
 

Example 10

From project android-client, under directory /xwiki-android-components/src/org/xwiki/android/components/objecteditor/.

Source file: ObjectEditor.java

  16 
vote

private void initObjectEditor(){
  setOrientation(LinearLayout.VERTICAL);
  setScrollBarStyle(LinearLayout.SCROLLBARS_INSIDE_OVERLAY);
  LinearLayout innerLayout=new LinearLayout(context);
  innerLayout.setOrientation(LinearLayout.VERTICAL);
  innerLayout.setScrollBarStyle(LinearLayout.SCROLLBARS_INSIDE_OVERLAY);
  ScrollView scrollView=new ScrollView(context);
  for (int i=0; i < object.properties.size(); i++) {
    tag=i;
    TextView textViewName=new TextView(context);
    textViewName.setText(object.properties.get(i).getName());
    textViewName.setTextSize(textViewName.getTextSize() + 2.0f);
    innerLayout.addView(textViewName);
    final EditText editTextValue=new EditText(context);
    editTextValue.setTag(tag);
    editTextValue.setText(object.properties.get(i).getValue());
    editTextValue.addTextChangedListener(new TextWatcher(){
      public void afterTextChanged(      Editable s){
        int currentTag=(Integer)editTextValue.getTag();
        object.properties.get(currentTag).setValue(s.toString());
        Log.d("current Tag",String.valueOf(currentTag));
        Log.d("value changed",object.properties.get(currentTag).getValue());
      }
      public void beforeTextChanged(      CharSequence s,      int start,      int count,      int after){
      }
      public void onTextChanged(      CharSequence s,      int start,      int before,      int count){
      }
    }
);
    innerLayout.addView(editTextValue);
  }
  scrollView.addView(innerLayout);
  addView(scrollView);
}
 

Example 11

From project Catroid-maven-playground, under directory /src/main/java/at/tugraz/ist/catroid/ui/dialogs/.

Source file: EditDialog.java

  16 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  setContentView(R.layout.dialog_edit_text);
  setCanceledOnTouchOutside(true);
  okButton=(Button)findViewById(R.id.dialog_edit_dialog_ok_button);
  editText=(EditText)findViewById(R.id.dialog_edit_dialog_edit_text);
  editText.addTextChangedListener(new TextWatcher(){
    public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      if (s.length() == 0 || (s.length() == 1 && s.charAt(0) == '.')) {
        Toast.makeText(context,R.string.notification_invalid_text_entered,Toast.LENGTH_SHORT).show();
        okButton.setEnabled(false);
      }
 else {
        okButton.setEnabled(true);
      }
    }
    public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    public void afterTextChanged(    Editable s){
    }
  }
);
  this.setOnShowListener(new OnShowListener(){
    public void onShow(    DialogInterface dialog){
      InputMethodManager inputManager=(InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
      inputManager.showSoftInput(editText,InputMethodManager.SHOW_IMPLICIT);
    }
  }
);
  super.onCreate(savedInstanceState);
}
 

Example 12

From project finch, under directory /src/com/bourke/finch/fragments/.

Source file: NewTweetDialogFragment.java

  16 
vote

@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  View v=inflater.inflate(R.layout.fragment_dialog,container,false);
  mTextViewRemainingChars=(TextView)v.findViewById(R.id.textview_remaining_chars);
  mTextViewRemainingChars.setText(Constants.MAX_TWEET_LENGTH + "");
  EditText edittextCompose=(EditText)v.findViewById(R.id.edittext_compose);
  edittextCompose.addTextChangedListener(new TextWatcher(){
    public void afterTextChanged(    Editable s){
      int remainingChars=Constants.MAX_TWEET_LENGTH - s.length();
      mTextViewRemainingChars.setText(remainingChars + "");
      if (remainingChars < 0) {
        mTextViewRemainingChars.setTextColor(Color.RED);
      }
 else {
        mTextViewRemainingChars.setTextColor(Color.BLACK);
      }
    }
    public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
    }
  }
);
  Button buttonCancel=(Button)v.findViewById(R.id.button_cancel);
  buttonCancel.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View v){
      NewTweetDialogFragment.this.getDialog().dismiss();
    }
  }
);
  return v;
}
 

Example 13

From project Gibberbot, under directory /src/info/guardianproject/otr/app/im/app/.

Source file: ContactsPickerActivity.java

  16 
vote

@Override protected void onCreate(Bundle icicle){
  super.onCreate(icicle);
  setContentView(R.layout.contacts_picker_activity);
  if (!resolveIntent()) {
    if (Log.isLoggable(ImApp.LOG_TAG,Log.DEBUG)) {
      log("no data, finish");
    }
    finish();
    return;
  }
  EditText filter=(EditText)findViewById(R.id.filter);
  filter.addTextChangedListener(new TextWatcher(){
    public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      mFilter.filter(s);
    }
    public void afterTextChanged(    Editable s){
    }
  }
);
}
 

Example 14

From project gobandroid, under directory /src/org/ligi/gobandroid_hd/ui/recording/.

Source file: RecordingGameExtrasFragment.java

  16 
vote

@Override public View onCreateView(LayoutInflater inflater,ViewGroup container,Bundle savedInstanceState){
  LinearLayout.LayoutParams lp=new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);
  et=new EditText(getActivity());
  getGame().addGoGameChangeListener(this);
  et.setText(getGame().getActMove().getComment());
  et.setHint(R.string.enter_your_comments_here);
  et.setGravity(Gravity.TOP);
  et.setTextColor(this.getResources().getColor(R.color.text_color_on_board_bg));
  et.addTextChangedListener(new TextWatcher(){
    @Override public void afterTextChanged(    Editable s){
      getGame().getActMove().setComment(s.toString());
    }
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
    }
  }
);
  et.setLayoutParams(lp);
  return et;
}
 

Example 15

From project greenDAO, under directory /DaoExample/src/de/greenrobot/daoexample/.

Source file: NoteActivity.java

  16 
vote

protected void addUiListeners(){
  editText.setOnEditorActionListener(new OnEditorActionListener(){
    @Override public boolean onEditorAction(    TextView v,    int actionId,    KeyEvent event){
      if (actionId == EditorInfo.IME_ACTION_DONE) {
        addNote();
        return true;
      }
      return false;
    }
  }
);
  final View button=findViewById(R.id.buttonAdd);
  button.setEnabled(false);
  editText.addTextChangedListener(new TextWatcher(){
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      boolean enable=s.length() != 0;
      button.setEnabled(enable);
    }
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void afterTextChanged(    Editable s){
    }
  }
);
}
 

Example 16

From project greenhouse-android, under directory /src/com/springsource/greenhouse/events/sessions/.

Source file: EventSessionRatingActivity.java

  16 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.event_session_rating);
  textViewCount=(TextView)this.findViewById(R.id.event_session_rating_count);
  textWatcher=new TextWatcher(){
    public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      textViewCount.setText(String.valueOf(MAX_LENGTH - s.length()));
    }
    public void afterTextChanged(    Editable s){
    }
  }
;
  final EditText editText=(EditText)findViewById(R.id.event_session_rating_text);
  editText.addTextChangedListener(textWatcher);
  final Button submitButton=(Button)findViewById(R.id.event_session_rating_submit);
  submitButton.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View v){
      InputMethodManager inputMethodManager=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
      EditText editText=(EditText)findViewById(R.id.event_session_rating_text);
      inputMethodManager.hideSoftInputFromWindow(editText.getWindowToken(),0);
      submitRating();
    }
  }
);
  final Button selectStartButton=(Button)findViewById(R.id.event_session_rating_select_star);
  selectStartButton.setOnClickListener(new View.OnClickListener(){
    public void onClick(    View v){
      showSelectStarRatingDialog();
    }
  }
);
}
 

Example 17

From project OAK, under directory /oak-demos/src/oak/demo/.

Source file: CancelEditTextActivity.java

  16 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.cancel_edit_text_demo);
  RelativeLayout attr=(RelativeLayout)findViewById(R.id.attribution);
  attr.setOnClickListener(new View.OnClickListener(){
    @Override public void onClick(    View view){
      Intent i=new Intent(Intent.ACTION_VIEW);
      i.setData(Uri.parse("http://www.willowtreeapps.com"));
      startActivity(i);
    }
  }
);
  final CancelEditText cancelEditText=(CancelEditText)findViewById(R.id.cancel_edit_one);
  cancelEditText.addTextChangedListener(new TextWatcher(){
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      if (cancelEditText.getText().length() == 0) {
        Toast.makeText(CancelEditTextActivity.this,"The CancelEditText was cleared",1000).show();
      }
    }
    @Override public void afterTextChanged(    Editable s){
    }
  }
);
}
 

Example 18

From project ohmagePhone, under directory /src/org/ohmage/prompt/text/.

Source file: TextPrompt.java

  16 
vote

@Override public View getView(Context context){
  LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View layout=inflater.inflate(R.layout.prompt_text,null);
  EditText editText=(EditText)layout.findViewById(R.id.text);
  editText.setText(mText);
  editText.addTextChangedListener(new TextWatcher(){
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
    }
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void afterTextChanged(    Editable s){
      mText=s.toString().trim();
    }
  }
);
  return layout;
}
 

Example 19

From project Ohmage_Phone, under directory /src/org/ohmage/prompt/text/.

Source file: TextPrompt.java

  16 
vote

@Override public View getView(Context context){
  LayoutInflater inflater=(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  View layout=inflater.inflate(R.layout.prompt_text,null);
  EditText editText=(EditText)layout.findViewById(R.id.text);
  editText.setText(mText);
  editText.addTextChangedListener(new TextWatcher(){
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
    }
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void afterTextChanged(    Editable s){
      mText=s.toString().trim();
    }
  }
);
  return layout;
}
 

Example 20

From project platform_packages_apps_contacts, under directory /src/com/android/contacts/interactions/.

Source file: GroupNameDialogFragment.java

  16 
vote

@Override public Dialog onCreateDialog(Bundle savedInstanceState){
  final AlertDialog.Builder builder=new AlertDialog.Builder(getActivity());
  final LayoutInflater layoutInflater=LayoutInflater.from(builder.getContext());
  final View view=layoutInflater.inflate(R.layout.group_name_dialog,null);
  final EditText editText=(EditText)view.findViewById(R.id.group_label);
  initializeGroupLabelEditText(editText);
  builder.setTitle(getTitleResourceId());
  builder.setView(view);
  editText.requestFocus();
  builder.setPositiveButton(android.R.string.ok,new DialogInterface.OnClickListener(){
    @Override public void onClick(    DialogInterface dialogInterface,    int whichButton){
      onCompleted(editText.getText().toString().trim());
    }
  }
);
  builder.setNegativeButton(android.R.string.cancel,null);
  final AlertDialog dialog=builder.create();
  dialog.setOnShowListener(new OnShowListener(){
    @Override public void onShow(    DialogInterface dialogInterface){
      updateOkButtonState(dialog,editText);
    }
  }
);
  editText.addTextChangedListener(new TextWatcher(){
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
    }
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void afterTextChanged(    Editable s){
      updateOkButtonState(dialog,editText);
    }
  }
);
  dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
  return dialog;
}
 

Example 21

From project platform_packages_apps_im, under directory /src/com/android/im/app/.

Source file: ContactsPickerActivity.java

  16 
vote

@Override protected void onCreate(Bundle icicle){
  super.onCreate(icicle);
  setContentView(R.layout.contacts_picker_activity);
  if (!resolveIntent()) {
    if (Log.isLoggable(ImApp.LOG_TAG,Log.DEBUG)) {
      log("no data, finish");
    }
    finish();
    return;
  }
  EditText filter=(EditText)findViewById(R.id.filter);
  filter.addTextChangedListener(new TextWatcher(){
    public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      mFilter.filter(s);
    }
    public void afterTextChanged(    Editable s){
    }
  }
);
}
 

Example 22

From project platform_packages_apps_mms, under directory /src/com/android/mms/ui/.

Source file: BasicSlideEditorView.java

  16 
vote

@Override public void onFinishInflate(){
  mImageView=(ImageView)findViewById(R.id.image);
  mAudioView=findViewById(R.id.audio);
  mAudioNameView=(TextView)findViewById(R.id.audio_name);
  mEditText=(EditText)findViewById(R.id.text_message);
  mEditText.addTextChangedListener(new TextWatcher(){
    public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      if (mOnTextChangedListenerEnabled && (mOnTextChangedListener != null)) {
        mOnTextChangedListener.onTextChanged(s.toString());
      }
    }
    public void afterTextChanged(    Editable s){
    }
  }
);
}
 

Example 23

From project SamyGo-Android-Remote, under directory /src/de/quist/app/samyGoRemote/.

Source file: Remote.java

  16 
vote

private void showInputDialog(){
  setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
  AlertDialog.Builder builder=new AlertDialog.Builder(this);
  builder.setTitle(R.string.text_input_title);
  EditText edit=new EditText(this);
  edit.addTextChangedListener(new TextWatcher(){
    public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
    }
    public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    public void afterTextChanged(    Editable s){
      TextSender sender=(TextSender)mSender;
      try {
        sender.sendText(s.toString());
      }
 catch (      IOException e) {
      }
catch (      InterruptedException e) {
      }
    }
  }
);
  builder.setView(edit);
  AlertDialog d=builder.create();
  d.setOnDismissListener(new OnDismissListener(){
    public void onDismiss(    DialogInterface dialog){
      setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
  }
);
  d.show();
}
 

Example 24

From project sls, under directory /src/com/adam/aslfms/.

Source file: EditUserCredentials.java

  16 
vote

@Override protected void onBindDialogView(View view){
  super.onBindDialogView(view);
  mUsername=(EditText)view.findViewById(R.id.username);
  mPassword=(EditText)view.findViewById(R.id.password);
  mUsername.addTextChangedListener(new TextWatcher(){
    @Override public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
    }
    @Override public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    @Override public void afterTextChanged(    Editable s){
    }
  }
);
  mUsername.setText(settings.getUsername(mNetApp));
  mPassword.setText(settings.getPassword(mNetApp));
}
 

Example 25

From project SVQCOM, under directory /Core/src/com/ushahidi/android/app/.

Source file: DeploymentSearch.java

  16 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.deployment_search);
  setTitleFromActivityLabel(R.id.title_text);
  promptForDeployment();
  mTextView=(TextView)findViewById(R.id.search_deployment);
  mListView=(ListView)findViewById(R.id.deployment_list);
  mEmptyList=(TextView)findViewById(R.id.empty_list_for_deployments);
  mDeployments=new ArrayList<DeploymentsData>();
  deploymentAdapter=new DeploymentAdapter(this);
  registerForContextMenu(mListView);
  mHandler=new Handler();
  mTextView.addTextChangedListener(new TextWatcher(){
    public void afterTextChanged(    Editable arg0){
    }
    public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      showResults(s.toString());
    }
  }
);
  mListView.setOnItemClickListener(new OnItemClickListener(){
    public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      final String deploymentId=mDeployments.get(position).getId();
      if (isDeploymentActive(Integer.parseInt(deploymentId))) {
        goToReports();
      }
 else {
        ReportsTask reportsTask=new ReportsTask();
        reportsTask.appContext=DeploymentSearch.this;
        reportsTask.id=String.valueOf(deploymentId);
        reportsTask.execute();
      }
    }
  }
);
  showResults("");
  displayEmptyListText();
}
 

Example 26

From project SWE12-Drone, under directory /catroid/src/at/tugraz/ist/catroid/ui/dialogs/.

Source file: EditDialog.java

  16 
vote

@Override protected void onCreate(Bundle savedInstanceState){
  requestWindowFeature(Window.FEATURE_NO_TITLE);
  setContentView(R.layout.dialog_edit_text);
  setCanceledOnTouchOutside(true);
  okButton=(Button)findViewById(R.id.dialog_edit_dialog_ok_button);
  editText=(EditText)findViewById(R.id.dialog_edit_dialog_edit_text);
  editText.addTextChangedListener(new TextWatcher(){
    public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
      if (s.length() == 0 || (s.length() == 1 && s.charAt(0) == '.')) {
        Toast.makeText(context,R.string.notification_invalid_text_entered,Toast.LENGTH_SHORT).show();
        okButton.setEnabled(false);
      }
 else {
        okButton.setEnabled(true);
      }
    }
    public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    public void afterTextChanged(    Editable s){
    }
  }
);
  this.setOnShowListener(new OnShowListener(){
    public void onShow(    DialogInterface dialog){
      InputMethodManager inputManager=(InputMethodManager)context.getSystemService(Context.INPUT_METHOD_SERVICE);
      inputManager.showSoftInput(editText,InputMethodManager.SHOW_IMPLICIT);
    }
  }
);
  super.onCreate(savedInstanceState);
}
 

Example 27

From project TextSecure, under directory /src/org/thoughtcrime/securesms/contacts/.

Source file: RecipientsEditor.java

  16 
vote

public RecipientsEditor(Context context,AttributeSet attrs){
  super(context,attrs,android.R.attr.autoCompleteTextViewStyle);
  mContext=context;
  mTokenizer=new RecipientsEditorTokenizer(context,this);
  setTokenizer(mTokenizer);
  setImeOptions(EditorInfo.IME_ACTION_NEXT);
  addTextChangedListener(new TextWatcher(){
    private Annotation[] mAffected;
    public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
      mAffected=((Spanned)s).getSpans(start,start + count,Annotation.class);
    }
    public void onTextChanged(    CharSequence s,    int start,    int before,    int after){
      if (before == 0 && after == 1) {
        char c=s.charAt(start);
        if (c == ',' || c == ';') {
          mLastSeparator=c;
        }
      }
    }
    public void afterTextChanged(    Editable s){
      if (mAffected != null) {
        for (        Annotation a : mAffected) {
          s.removeSpan(a);
        }
      }
      mAffected=null;
    }
  }
);
}
 

Example 28

From project uberdust-android, under directory /src/eu/uberdust/mobileclient/.

Source file: SearchActivity.java

  16 
vote

protected void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_search);
  setTitleFromActivityLabel(R.id.title_text);
  fillMaps=new ArrayList<HashMap<String,Object>>();
  fillMapsVirtual=new ArrayList<HashMap<String,Object>>();
  search=(EditText)findViewById(R.id.search);
  search.addTextChangedListener(new TextWatcher(){
    public void afterTextChanged(    Editable s){
      if (!s.toString().equals("")) {
        itemSearch(s.toString());
      }
    }
    public void beforeTextChanged(    CharSequence s,    int start,    int count,    int after){
    }
    public void onTextChanged(    CharSequence s,    int start,    int before,    int count){
    }
  }
);
  lv=(ListView)findViewById(R.id.list);
  lv.setOnItemClickListener(new OnItemClickListener(){
    public void onItemClick(    AdapterView<?> parent,    View view,    int position,    long id){
      String nodename=((TextView)view.findViewById(R.id.node)).getText().toString();
      if (nodename.contains("virtual")) {
        ((GlobalData)getApplicationContext()).setCurrentRoom((RoomTree)fillMapsVirtual.get(position - real - 2).get("ObjectRoom"));
        changetoVirturalRoom((Integer)fillMapsVirtual.get(position - real - 2).get("position"));
      }
 else {
        ((GlobalData)getApplicationContext()).setCurrentRoom((RoomTree)fillMaps.get(position - 1).get("ObjectRoom"));
        Log.d("position",Integer.toString((Integer)fillMaps.get(position - 1).get("position")));
        changetoRoom((Integer)fillMaps.get(position - 1).get("position"));
      }
    }
  }
);
}
 

Example 29

From project Ushahidi_Android, under directory /Core/src/com/ushahidi/android/app/ui/phone/.

Source file: ListMapActivity.java

  16 
vote

@Override public void onCreate(Bundle savedInstanceState){
  super.onCreate(savedInstanceState);
  actionBar.setDisplayHomeAsUpEnabled(false);
  registerForContextMenu(listView);
  this.dialog=new ProgressDialog(this);
  this.dialog.setCancelable(true);
  this.dialog.setIndeterminate(true);
  this.dialog.setMessage(getString(R.string.please_wait));
  Preferences.loadSettings(this);
  if (view != null) {
    view.mSearchMap.addTextChangedListener(new TextWatcher(){
      public void afterTextChanged(      Editable arg0){
      }
      public void beforeTextChanged(      CharSequence s,      int start,      int count,      int after){
      }
      public void onTextChanged(      CharSequence s,      int start,      int before,      int count){
        if (!(TextUtils.isEmpty(s.toString()))) {
          filter=s.toString();
          mHandler.post(filterMapList);
        }
 else {
          mHandler.post(fetchMapList);
        }
      }
    }
);
  }
}
 

Example 30

From project gauges-android, under directory /app/src/main/java/com/github/mobile/gauges/authenticator/.

Source file: GaugesAuthenticatorActivity.java

  15 
vote

private TextWatcher validationTextWatcher(){
  return new TextWatcherAdapter(){
    public void afterTextChanged(    Editable gitDirEditText){
      updateUIWithValidation();
    }
  }
;
}
 

Example 31

From project Jota-Text-Editor, under directory /src/jp/sblo/pandora/jota/text/.

Source file: SpannableStringBuilder.java

  15 
vote

private TextWatcher[] sendTextWillChange(int start,int before,int after){
  TextWatcher[] recip=getSpans(start,start + before,TextWatcher.class);
  int n=recip.length;
  for (int i=0; i < n; i++) {
    recip[i].beforeTextChanged(this,start,before,after);
  }
  return recip;
}