`
Dong_Android
  • 浏览: 26753 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论
文章列表
通常在开发Android显示网络图片时,通常会遇到因手机屏幕大小的不同,显示图片变形的问题。所以我们在显示图片时通过获取图片的大小,再计算出控件应该显示的大小,这样图片显示不会出现拉伸的问题。以下就是怎样获取 ...
/** * MD5 加密 * @param tastr * @return 字符串 */ public static String getMD5(String tastr) {     byte[] source = tastr.getBytes();     String s = null;     char hexDigits[] = { // 用来将字节转换成 16 进制表示的字符     '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd','e', 'f' };     try ...
/** * 判断时间是否为今日 * @param sdate * @return boolean */ public static boolean isToday(String time){ boolean bool = false; Date date = ToDateTime(time, 1);// 将时间格式化 Date today = new Date(); if(time != null){ String nowDate = ToStringTime(6, today); String timeDate = ToStringTime(6, date);     if( ...
/** * 生成随机串(包含 字母+数字) * @param pwd_len   // 随机数的长度 * @return 字符串 */ public static String genRandomNum(int pwd_len) { final int maxNum = 50; int i; int count = 0; char[] str = { 'a', 'A', 'b', 'B', 'c', 'C', 'd', 'D', 'e', 'E', 'f', 'F', 'g', 'G', 'h', 'H', 'i', 'I', 'j', 'J', 'k', 'K', 'l', ' ...
/** * 生成随机数纯数字 * @param length  // 随机数的长度 * @return */ public static String getRandom(int length) { Random random = new Random(); String rr = ""; Set set = new HashSet(); while (set.size() < length) { set.add(random.nextInt(10)); } Iterator iterator = set.iterator(); while ( ...
/** * 字符串去回车去空格 * @param str * @return */ public static String replaceBlank(String str) { String dest = ""; if (str != null) { Pattern p = Pattern.compile("\\s*|\t|\r|\n"); Matcher m = p.matcher(str); dest = m.replaceAll(""); } return dest; }
/** * 检测是否是手机号 * @param mobileNum * @return */ public static boolean isMobileNum(String mobileNum) { Pattern pattern = Pattern.compile("^(0|86|17951)?((13[0-9])|(145)|(147)|(170)|(17[6-8])|(15[^4,\\D])|(18[0-9]))\\d{8}$"); Matcher matcher = pattern.matcher(mobileNum); return matcher. ...
/** 检测是否是Email **/ public static boolean isEmail(String email) { Pattern pattern = Pattern.compile("^(\\w)+(\\.\\w+)*@(\\w)+((\\.\\w{2,3}){1,3})$"); Matcher matcher = pattern.matcher(email); return matcher.matches(); }
/** * 检查是否固话 * @param phoneNum * @return */ public static boolean isPhoneNum(String phoneNum) { Pattern pattern = Pattern.compile("0\\d{2,3}-\\d{7,8}"); Matcher matcher = pattern.matcher(phoneNum); return matcher.matches(); }
/** 判断字符串中是否包含数字 **/ public static boolean isContainsNum(String input) { int len = input.length(); for (int i = 0; i < len; i++) { if (Character.isDigit(input.charAt(i))) { return true; } } return false; }
/** 判断字符串中是否包含字母  **/ public static boolean isContainsLetter(String input){ if(!StringUtil.isNull(input)){ Matcher matcher = Pattern.compile(".*[a-zA-Z]+.*").matcher(input); return matcher.matches(); }else{ return false; } }
/** 格式化价格**/ public static String formatPrice(Double price){ String result = ""; try { DecimalFormat decimalFormat = new DecimalFormat("0.00"); result = decimalFormat.format(price); } catch (Exception e) { } return result; }
       Android中最常用的加载图片的Demo,本文是自己在开发过程中总结的一篇文章。主要功能就是将网络的图片显示到手机上,并将第一次加载下来的图片保存到本地,第二次访问时如果本地还存在就直接读取本地的图片。用法很简单,只需将util包下的loadImage包中的所有文件和ImageTools文件拷贝到你的项目中。在Activity中给控件赋值时,直接引用 String imageUrl = LoadImageActivity.class.getName() + "-" + list.get(position); String tag = imageUrl ...
/** * 计算两个时间之间的间隔天数 time2大时间, time1小时间 * @param time2 * @param time1 * @return */ public static int CalculateIntervalDays(String time2, String time1){ int IntervalDays = 0; Date date2 = null; Date date1 = null; try { Calendar calendar = Calendar.getInstance(); date2 = DateUtil.ToDateTime ...
/** * 判断当前时间是上午还是下午 * @return */ public static String newDateIsAMOrPM(){ String info = null; String time = ToStringTime(4, new Date()); String hour = time.substring(0, 2); String minutes = time.substring(3, 5); int difference = 0; if(hour.substring(0, 1).equals("0")){ difference ...
Global site tag (gtag.js) - Google Analytics