完美的按键机输入Editext,性能稳定,扩展性强

话不多说,直接上代码:

package com.sage.org.view;

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Handler;
import android.text.Editable;
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextWatcher;
import android.text.style.ForegroundColorSpan;
import android.util.AttributeSet;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;

import com.vogtec.uibase.R;
import com.vogtec.uibase.contacts.MM;
import com.vogtec.uibase.utils.AppUtils;

import java.util.ArrayList;

public class CustomEditTextView extends EditText implements TextWatcher, View.OnKeyListener {
   
	private InputStatusChangeLinster inputStatusChangeLinster;
	private boolean showPop = true;
	private static final int SHOW_SELECT_TIME = 1300;
	/**
	 * 0:Abc,1:abc,2:ABC,3:123,4:2aB,4:phone
	 */
	private int inputType = 0;
	public static final int INPUTTYPE_Abc = 1;
	public static final int INPUTTYPE_abc = 1 << 1;
	public static final int INPUTTYPE_ABC = 1 << 2;
	public static final int INPUTTYPE_123 = 1 << 3;
	public static final int INPUTTYPE_2aB = 1 << 4;
	public static final int INPUTTYPE_phone = 1 << 5;
	public static final int INPUTTYPE_phone2 = 1 << 6;
	private static String[] inputStringType = new String[]{
   "Abc", "abc", "ABC", "123", "2aB", "phone", "phone2"};
	static {
   
		if (MM.isMfs(MM.MF_POLMOB)){
   
			inputStringType = new String[]{
   "Abc", "abc", "ABC", "123", "2aB", "Telefon", "Telefon2"};
		}
	}
	private final boolean[] selectInputStringType = new boolean[]{
   true, true, true, true, true, false, false};
	private static String[][][] lib_char_abc;
	private static final String[][][] lib_char_abc_en = {
   
			{
   {
   " "},
					{
   ".", "*", "#", ":", ",", "&", "@", "!", "'", "$", "%", "\"", "~", "(", ")", "+", "-", "/", "?",
							";", "<", "=", ">", "[", "]", "_",},
					{
   "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"},
					{
   ".", "*", "#"}}, // Abc
			{
   {
   " "},
					{
   ".", "*", "#", ":", ",", "&", "@", "!", "'", "$", "%", "\"", "~", "(", ")", "+", "-", "/", "?",
							";", "<", "=", ">", "[", "]", "_",},
					{
   "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"},
					{
   ".", "*", "#"}}, // abc
			{
   {
   " "},
					{
   ".", "*", "#", ":", ",", "&", "@", "!", "'", "$", "%", "\"", "~", "(", ")", "+", "-", "/", "?",
							";", "<", "=", ">", "[", "]", "_",},
					{
   "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"},
					{
   ".", "*", "#"}}, // ABC
			{
   {
   "0"}, {
   "1"}, {
   "2"}, {
   "3"}, {
   "4"}, {
   "5"}, {
   "6"}, {
   "7"}, {
   "8"}, {
   "9"}, {
   "."}}, // 123
			{
   {
   "0", " "},

					{
   "1", ".", "*", "#", ":", ",", "&", "@", "!", "'", "$", "%", "\"", "~", "(", ")", "+", "-", "/",
							"?", ";", "<", "=", ">", "[", "]", "_",},
					{
   "2", "a", "A", "b", "B", "c", "C"},
					{
   "3", "d", "D", "e", "E", "f", "F"},
					{
   "4", "g", "G", "h", "H", "i", "I"}, {
   "5", "j", "J", "k", "K", "l", "L"},
					{
   "6", "m", "M", "n", "N", "o", "O"},
					{
   "7", "p", "P", "q", "Q", "r", "R", "s", "S"},
					{
   "8", "t", "T", "u", "U", "v", "V"},
					{
   "9", "w", "W", "x", "X", "y", "Y", "z", "Z"}, {
   ".", "*", "#"}}, // 2aB
			{
   {
   "0"}, {
   "1"}, {
   "2"}, {
   "3"}, {
   "4"}, {
   "5"}, {
   "6"}, {
   "7"}, {
   "8"}, {
   "9"}, {
   "+"}}, // phone
			{
   {
   "0"}, {
   "1"}, {
   "2"}, {
   "3"}, {
   "4"}, {
   "5"}, {
   "6"}, {
   "7"}, {
   "8"}, {
   "9"}, {
   "*", "+", "#"}}, // phone2
	};
	//葡萄牙语
	private static final String[][][] lib_char_abc_pt = {
   
			{
   {
   " "},
					{
   ".", "*", "#", ":", ",", "&", "@", "!", "'", "$", "%", "\"", "~", "(", ")", "+", "-", "/", "?",
							";", "<", "=", ">", "[", "]", "_",},
					{
   "a", "b", "c", "á", "à", "â", "ã", "ç"}, {
   "d", "e", "f", "é", "ê"},
					{
   "g", "h", "i", "í"}, {
   "j", "k", "l"}, {
   "m", "n", "o", "ó", "ô", "õ"},
					{
   "p", "q", "r", "s"}, {
   "t", "u", "v", "ú", "ü"}, {
   
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值