Back to project page RobolectricSample.
The source code is released under:
MIT License
If you think the Android project RobolectricSample listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.pivotallabs; // www . j a va 2s. co m import android.text.Editable; import android.view.View; import android.widget.EditText; public class ViewEnablingTextWatcher { private View toEnable; private EditText[] toWatch; public ViewEnablingTextWatcher(View toEnable, EditText... toWatch) { super(); this.toEnable = toEnable; this.toWatch = toWatch; ChangeListener changeListener = new ChangeListener(); for (EditText editText : toWatch) { editText.addTextChangedListener(changeListener); } } private void setViewEnabledState() { boolean enabledState = true; for (EditText editText : toWatch) { CharSequence text = editText.getText(); if (text == null || text.toString().trim().length() == 0) { enabledState = false; break; } } toEnable.setEnabled(enabledState); } private class ChangeListener extends StubTextWatcher { @Override public void afterTextChanged(Editable s) { setViewEnabledState(); } } }