Skip to content

Instantly share code, notes, and snippets.

@daichan4649
Created October 17, 2013 07:22
Show Gist options
  • Save daichan4649/7020485 to your computer and use it in GitHub Desktop.
Save daichan4649/7020485 to your computer and use it in GitHub Desktop.
入力フィルタ(半角英数のみ入力可)
/**
* 入力フィルタ(半角英数)
* @see <a href="http://y-anz-m.blogspot.jp/2010/10/androidfilter.html">半角英数フィルタ</a>
*/
class AlphaNumericFilter implements InputFilter {
@Override
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
if (source.toString().matches("^[a-zA-Z0-9]+$")) {
return source;
} else {
return "";
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment