Created
October 17, 2013 07:22
-
-
Save daichan4649/7020485 to your computer and use it in GitHub Desktop.
入力フィルタ(半角英数のみ入力可)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 入力フィルタ(半角英数) | |
* @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