我正在尝试使用2个ImageView和一组过渡创建幻灯片。我使用通用图像加载器来解码位图,一切都适用于5-6张幻灯片。之后,活动冻结了。我在logcat中不时遇到的唯一例外是
12-11 17:36:16.545 22794-22794/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lucon.GrannyLauncher/com.lucon.GrannyLauncher.activities.Launcher}: android.content.res.Resources$NotFoundException: Resource ID #0x7f030005
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.access$700(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f030005
at android.content.res.Resources.getValue(Resources.java)
at android.content.res.Resources.loadXmlResourceParser(Resources.java)
at android.content.res.Resources.getLayout(Resources.java)
at android.view.LayoutInflater.inflate(LayoutInflater.java)
at android.view.LayoutInflater.inflate(LayoutInflater.java)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java)
at android.app.Activity.setContentView(Activity.java)
at com.lucon.GrannyLauncher.activities.Launcher.onCreate(Launcher.java:38)
at android.app.Activity.performCreate(Activity.java)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java)
at android.app.ActivityThread.access$700(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java)
at android.os.Handler.dispatchMessage(Handler.java)
at android.os.Looper.loop(Looper.java)
at android.app.ActivityThread.main(ActivityThread.java)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java)
at dalvik.system.NativeStart.main(Native Method)
我用于创建幻灯片的方法是:
private void startSlideShow(){
loadedViews.add(image1);
loadedViews.add(image2);
imageLoader.displayImage("file://" + slideShowData.getNextImagePath(), image1);
imageLoader.displayImage("file://" + slideShowData.getNextImagePath(), image2);
final Handler transitionHandler = new Handler();
final Runnable transition = new Runnable() {
@Override
public void run() {
final Runnable that = this;
ImageView currentView = loadedViews.peekFirst();
imageLoader.displayImage("file://" + slideShowData.getNextImagePath(), currentView, new ImageLoadingListener() {
@Override
public void onLoadingStarted(String s, View view) {
}
@Override
public void onLoadingFailed(String s, View view, FailReason failReason) {
}
@Override
public void onLoadingComplete(String s, View view, Bitmap bitmap) {
view.bringToFront();
view.startAnimation(animations.get(rand.nextInt(animations.size() - 1)));
loadedViews.add(((ImageView)view));
transitionHandler.postDelayed(that, 15000);
}
@Override
public void onLoadingCancelled(String s, View view) {
}
});
}
};
transitionHandler.postDelayed(transition, 6000);
}
任何人都可以帮我解决这个奇怪的问题吗?我无法理解。
答案 0 :(得分:0)
我解决了这个问题。当应用程序停止响应时,我设法通过查看dalvik跟踪来修复它。
我发现了这个
"main" prio=5 tid=1 SUSPENDED
| group="main" sCount=1 dsCount=0 obj=0x41388508 self=0x41066b78
| sysTid=31195 nice=0 sched=0/0 cgrp=apps handle=1074868016
| schedstat=( 43157155482 3673056299 23355 ) utm=4204 stm=111 core=1
at java.util.LinkedList.contains(LinkedList.java:~488)
at com.app.data.SlideShowData.getNextImagePath(SlideShowData.java:57)
at com.app.custom.view.ImageSlideShow$1.run(ImageSlideShow.java:140)
at android.os.Handler.handleCallback(Handler.java:-1)
at android.os.Handler.dispatchMessage(Handler.java:-1)
at android.os.Looper.loop(Looper.java:-1)
at android.app.ActivityThread.main(ActivityThread.java:-1)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:-1)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:-1)
at dalvik.system.NativeStart.main(Native Method)
我去了SlideShowData并发现由于自定义队列,程序陷入了一个while循环。愚蠢的错误。