天道酬勤,学无止境

image-load

检测图像加载(Detect image load)

问题 是否可以通过jQuery加载图像来进行检测? 回答1 您可以使用.load()事件处理程序,如下所示: $("#myImg").load(function() { alert('I loaded!'); }).attr('src', 'myImage.jpg'); 在设置源之前,请确保将其附加,否则,在附加处理程序以监听它之前,可能已经触发了该事件(例如,从缓存加载)。 如果这是不可行的(设置src后绑定)时,一定要检查它的加载和启动它自己,是这样的: $("#myImg").load(function() { alert('I loaded!'); }).each(function() { if(this.complete) $(this).load(); }); 回答2 使用普通的Javascript一样简单: // Create new image var img = new Image(); // Create var for image source var imageSrc = "http://example.com/blah.jpg"; // define what happens once the image is loaded. img.onload = function() { // Stuff to do after image load (

2021-04-14 11:08:53    分类:技术分享    jquery   image-load

Android OutOfMemoryError :?(Android OutOfMemoryError:?)

问题 我偶尔在我的一个应用程序中收到OutOfMemoryError: (Heap Size=49187KB, Allocated=41957KB) 。 我该怎么做才能诊断出来? 01-09 10:32:02.079: E/dalvikvm(8077): Out of memory: Heap Size=49187KB, Allocated=41957KB, Limit=49152KB 01-09 10:32:02.079: E/dalvikvm(8077): Extra info: Footprint=48611KB, Allowed Footprint=49187KB, Trimmed=7852KB 01-09 10:32:02.079: D/skia(8077): --- decoder->decode returned false 01-09 10:32:02.079: D/AndroidRuntime(8077): Shutting down VM 01-09 10:32:02.079: W/dalvikvm(8077): threadid=1: thread exiting with uncaught exception (group=0x40a97228) 01-09 10:32:02.079: E/AndroidRuntime(8077): FATAL

2021-04-07 15:50:50    分类:技术分享    android   out-of-memory   image-load

Android OutOfMemoryError:?

I am sporadically getting an OutOfMemoryError: (Heap Size=49187KB, Allocated=41957KB) in one of my apps. What can I do to diagnose this? 01-09 10:32:02.079: E/dalvikvm(8077): Out of memory: Heap Size=49187KB, Allocated=41957KB, Limit=49152KB 01-09 10:32:02.079: E/dalvikvm(8077): Extra info: Footprint=48611KB, Allowed Footprint=49187KB, Trimmed=7852KB 01-09 10:32:02.079: D/skia(8077): --- decoder->decode returned false 01-09 10:32:02.079: D/AndroidRuntime(8077): Shutting down VM 01-09 10:32:02.079: W/dalvikvm(8077): threadid=1: thread exiting with uncaught exception (group=0x40a97228) 01-09 10

2021-03-27 23:01:24    分类:问答    android   out-of-memory   image-load

Detect image load

Is it possible to detect once an image has been loaded with jQuery?

2021-03-25 06:51:02    分类:问答    jquery   image-load