android点滴5
16lz
2021-01-23
Android Studio Tips -- 布局预览
http://www.open-open.com/lib/view/open1437404317881.html
使用Android Support Annotations优化你的代码
http://www.open-open.com/lib/view/open1437448397115.html
UrlQuerySanitizer
一个很方便用来处理url链接的工具类,之前开发过程中遇到需要处理支付宝网页url,获取里面post参数,当时使用String的各种接口进行处理,如果用UrlQuerySanitizer的话就简单多了。比如现在有个Url=http://example.com/?name=Mark,我们使用UrlQuerySanitizer拿到name的值:
Simple example:
UrlQuerySanitizer sanitizer = new UrlQuerySanitizer();sanitizer.setAllowUnregisteredParamaters(true);sanitizer.parseUrl("http://example.com/?name=Joe+User"); String name = sanitizer.getValue("name")); // name now contains "Joe_User" Register ValueSanitizers to customize the way individual parameters are sanitized:
UrlQuerySanitizer sanitizer = new UrlQuerySanitizer();sanitizer.registerParamater("name", UrlQuerySanitizer.createSpaceLegal());sanitizer.parseUrl("http://example.com/?name=Joe+User");String name = sanitizer.getValue("name")); // name now contains "Joe User". (The string is first decoded, which // converts the '+' to a ' '. Then the string is sanitized, which // converts the ' ' to an '_'. (The ' ' is converted because the default unregistered parameter sanitizer does not allow any special characters, and ' ' is a special character.)
/** * 获得url中对应key的参数值(value) * * @param url * @param key * @return */public String getParameter(String url, String key) {if (!TextUtils.isEmpty(url)) {UrlQuerySanitizer sanitizer = new UrlQuerySanitizer(url);sanitizer.setAllowUnregisteredParamaters(true);return sanitizer.getValue(key);}return null;}
PhoneNumberUtils
public static String formatNumber (String phoneNumber, String defaultCountryIso)
PhoneNumverUtils提供了一系列方法用来格式化电话号码
String num = "031185203009";PhoneNumberUtils util = new PhoneNumberUtils();String numFormated = util.formatNumber(num,"CN");
numFormated = 0311-8520-3009
Breaks the given number down and formats it according to the rules for the country the number is from.
Parameters
source The phone number to format
Returns
A locally acceptable formatting of the input, or the raw input if formatting rules aren't known for the number
Android Design Support Library使用详解
http://blog.csdn.net/eclipsexys/article/details/46349721