EditText小写字母自动转换成大写(注:设置之后只能显示大写字母)

 1 import android.text.method.ReplacementTransformationMethod;
 2 /**
 3  * @author cloud
 4  * 
 5  */
 6 public class AllCapTransformationMethod extends ReplacementTransformationMethod {
 7   @Override
 8   protected char[] getOriginal() {
 9       char[] aa= { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
10       return aa;
11   }
12   @Override
13   protected char[] getReplacement() {
14       char[] AA= { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z' };
15       return AA;
16   }
17 }
18 //将需要转换的edittext实现该方法
19 editext.setTransformationMethod(new AllCapTransformationMethod ());

 

posted @ 2015-10-14 22:26  Cloud_9527  阅读(715)  评论(0编辑  收藏  举报