android点滴5

一些小效果的实现

http://www.see-source.com/blog/300000032/1425.html

跨应用(同一个程序内的多个进程之间)数据读写的替代类(可替代SharedPreferences)

https://github.com/grandcentrix/tray

Android常用开源框架Proguard混淆解决方案

https://github.com/offbye/Android-ProGuardRules

五年Android开发,让我“刻骨铭心”的那些坑

http://www.open-open.com/lib/view/open1472741571941.html

Android实现不重复启动APP的方法

http://www.open-open.com/lib/view/open1447489467116.html

CoolAndroidApis整理(一)

http://oakzmm.com/2015/08/04/cool-Android-api/

http://oakzmm.com/2015/08/11/cool-Android-api-2/

http://oakzmm.com/2015/09/07/cool-android-api-3/

http://www.open-open.com/news/view/ea7c88

http://www.open-open.com/news/view/95a84a

不要在Android的Application对象中缓存数据!

在Androidlibrary中不能使用switch-case语句访问资源ID的原因分析及解决方案

禁止RatingBar选择或改变

加这个属性,android:isIndicator="true"

setDuplicateParentStateEnabled子控件获得父控件的状态,对应android:duplicateParentState

setAddStatesFromChildren同上相反,对应android:addStatesFromChildren

这两个属性不能同时设置,同时设置会产生异常

Android开发最佳实践

http://www.csdn.net/article/2015-10-05/2825847

你还在写一堆的findViewById()吗?

自定义一个方法:

public <T T extends View> T $(int viewID) {
    return (T) findViewById(viewID);
}

然后不管是什么类型的View,直接一个$方法搞定,类似JQuery

Android中strings.xml占位符

<stringname="data">整数型:%1$d,浮点型:%2$.3f,字符串:%3$s</string>

其中%后面是占位符的位置,从1开始,

$后面是填充数据的类型

%d:表示整数型;

%f:表示浮点型,其中f前面的.3表示小数的位数

%s:表示字符串

String data = getResources().getString(R.string.data);
data = String.format(data, 100, 100.333, "2014-02-26");
//整数型:100,浮点型:100.333,字符串:2014-02-26

动态设置全屏,退出全屏

/**设置全屏**/
WindowManager.LayoutParams params = getWindow().getAttributes();
params.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(params);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
 
/**退出全屏**/
WindowManager.LayoutParams params = getWindow().getAttributes();
params.flags &= (~WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().setAttributes(params);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);

CoolAndroidApis整理(一)

http://www.open-open.com/lib/view/open1439219767176.html

http://blog.danlew.net/2014/03/30/android-tips-round-up-part-1/

AndroidStudioTips--布局预览

http://www.open-open.com/lib/view/open1437404317881.html

使用AndroidSupportAnnotations优化你的代码

http://www.open-open.com/lib/view/open1437448397115.html

UrlQuerySanitizer

一个很方便用来处理url链接的工具类,之前开发过程中遇到需要处理支付宝网页url,获取里面post参数,当时使用String的各种接口进行处理,如果用UrlQuerySanitizer的话就简单多了。比如现在有个Url=http://example.com/?name=Mark,我们使用UrlQuerySanitizer拿到name的值:

Simpleexample:

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

publicstaticStringformatNumber(StringphoneNumber,StringdefaultCountryIso)

PhoneNumverUtils提供了一系列方法用来格式化电话号码

String num = "031185203009";
PhoneNumberUtils util = new PhoneNumberUtils();
String numFormated =  util.formatNumber(num,"CN");

numFormated=0311-8520-3009

Breaksthegivennumberdownandformatsitaccordingtotherulesforthecountrythenumberisfrom.

Parameters

sourceThephonenumbertoformat

Returns

Alocallyacceptableformattingoftheinput,ortherawinputifformattingrulesaren'tknownforthenumber

AndroidDesignSupportLibrary使用详解

http://blog.csdn.net/eclipsexys/article/details/46349721

相关推荐