android 字符长度限制
2017-12-20 14:24
155 查看
public static String handleText(String str, int maxLen) { if (TextUtils.isEmpty(str)) { return str; } int count = 0; int endIndex=0; for (int i = 0; i < str.length(); i++) { char item = str.charAt(i); if (item < 128) { count = count + 1; } else { count = count + 2; } if(maxLen==count || (item>=128 && maxLen+1==count)){ endIndex=i; } } if (count <= maxLen) { return str; } else { return str.substring(0, endIndex) + "..."; } }
相关文章推荐
- android中edittext特殊字符过滤和字符长度限制的最优方法
- 关于 android 中 edittext 特殊字符过滤和字符长度限制的最优方法
- 关于 android 中 edittext 特殊字符过滤和字符长度限制的最优方法
- android的logcat的message有字符长度的限制,超过将直接截断
- android 字符长度限制,中文2个字符 ,英文1个字符
- 关于android 中EditText 特殊字符过滤和字符长度限制的最优方法
- Android EditText输入限制最大字符长度 和 限制只能输入数字和字母(包含大小写)
- android editText 字符长度限制
- android的logcat的message有字符长度的限制,超过将直接截断
- 关于 android 中 edittext 特殊字符过滤和字符长度限制的最优方法
- Android EditText限制文字长度(中文算2字符,英文算1字符)
- 关于 android 中 edittext 特殊字符过滤和字符长度限制的最优方法
- 关于 android 中 edittext 特殊字符过滤和字符长度限制的最优方法
- Android EditText限制文字长度(中文算3字符,英文算1字符)
- 关于 android 中 edittext 特殊字符过滤和字符长度限制的最优方法
- android判断密码长度,限制长度为6到20个字符
- 关于 android 中 edittext 特殊字符过滤和字符长度限制的最优方法
- 关于android中edittext特殊字符过滤和字符长度限制的最优方法
- Android EditText 特殊字符过滤和字符输入长度限制
- Android输入框限制字符长度,字母自动大写