package com.example.view; import com.iflytek.voiceads.AdError; import com.iflytek.voiceads.AdKeys; import com.iflytek.voiceads.IFLYAdListener; import com.iflytek.voiceads.IFLYAdSize; import com.iflytek.voiceads.IFLYFullScreenAd; import android.content.Context; import android.text.Editable; import android.text.TextWatcher; import android.util.AttributeSet; import android.view.KeyEvent; import android.widget.EditText; import android.widget.Toast; public class HPEditText extends EditText { private boolean isRun = false; private String d = ""; private Context mContext; public HPEditText(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); this.mContext=context; setBankCardTypeOn(); } public HPEditText(Context context, AttributeSet attrs) { super(context, attrs); setBankCardTypeOn(); } public HPEditText(Context context) { super(context); setBankCardTypeOn(); } public void setBankCardTypeOn() { HPEditText.this.addTextChangedListener(new TextWatcher() { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (isRun) { isRun = false; return; } isRun = true; d = ""; String newStr = s.toString(); newStr = newStr.replace(" ", ""); int index = 0; while ((index + 4) < newStr.length()) { d += (newStr.substring(index, index + 4) + " "); index += 4; } d += (newStr.substring(index, newStr.length())); int i = getSelectionStart(); HPEditText.this.setText(d); try { if (i % 5 == 0 && before == 0) { if (i + 1 <= d.length()) { HPEditText.this.setSelection(i + 1); } else { HPEditText.this.setSelection(d.length()); } } else if (before == 1 && i < d.length()) { HPEditText.this.setSelection(i); } else if (before == 0 && i < d.length()) { HPEditText.this.setSelection(i); } else HPEditText.this.setSelection(d.length()); } catch (Exception e) { } } private void insertText(EditText editText, String mText) { editText.getText().insert(getSelectionStart(), mText); } @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void afterTextChanged(Editable s) { // Toast.makeText(mContext, "最中输入"+s, Toast.LENGTH_LONG).show(); } }); } }长安ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18982081108(备注:SSL证书合作)期待与您的合作!
另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。