首页 > 代码库 > 怎么设置输入的EditText字母自动大写
怎么设置输入的EditText字母自动大写
复于: 2013-09-06 09:06:25
package com.gainko.helper;
import android.text.method.ReplacementTransformationMethod;
/**
* @author Ivan
*
*/
public class AllCapTransformationMethod extends ReplacementTransformationMethod {
@Override
protected char[] getOriginal() {
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‘ };
return aa;
}
@Override
protected char[] getReplacement() {
char[] cc = { ‘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‘ };
return cc;
}
}
///
editext.setTransformationMethod(new AllCapTransformationMethod ());
import android.text.method.ReplacementTransformationMethod;
/**
* @author Ivan
*
*/
public class AllCapTransformationMethod extends ReplacementTransformationMethod {
@Override
protected char[] getOriginal() {
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‘ };
return aa;
}
@Override
protected char[] getReplacement() {
char[] cc = { ‘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‘ };
return cc;
}
}
///
editext.setTransformationMethod(new AllCapTransformationMethod ());
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。