function 里的 this 在不同的时候,会有不同的表现,一般会有以下四种情况
Invocation as a function
Invocation as a method
Invocation as a constructor
Invocatuon with the apply() and call() method继续阅读 »
I have a class that needs to obtain a reference to it's application's AssetManager. This class does not extend any sort of android UI class, so it doesn't have a getContext() method, or anything similar. Is there some sort of static Context.getCurrentApplicationContext() type of method?
To clarify: my class is inte继续阅读 »
顾名思义,装饰模式就是给一个对象增加一些新的功能,而且是动态的,要求装饰对象和被装饰对象实现同一个接口,装饰对象持有被装饰对象的实例,关系图如下:
Source类是被装饰类,Decorator类是一个装饰类,可以为Source类动态的添加一些功能,代码如下:
public interface Sourceable {
public void method();
}
public class Source implements Sourceable {
@Override
public void method() {
System.out.println("the original 继续阅读 »
近日,我们的应用,在编译的时候不幸的遇到这个错误
Conversion to Dalvik format failed: Unable to execute dex: method ID not in [0, 0xffff]: 65536
这才让我意识到原来我们的程序中,方法数已经超过了65536。在之前,已经知道了android系统的java虚拟机dalvik在执行java程序时,使用原生类型short来索引dex文件中的方法,因此方法数就呗限制在65536了。之前我一直以为,这个数量已经很大了,不会达到上限,结果今天就达到了。
不过这个东西呢,我们也是很容易的进行解决的,因为,就在去年不久前,google官方提供了多dex继续阅读 »